举例

#!/bin/bash
echo "please input a number list:"
read -a arrs
for((i=0;i<${#arrs[@]};i++))
{
mindex=i;
for((j=i+1;j<${#arrs[@]};j++))
{
if [[ ${arrs[j]} -lt ${arrs[mindex]} ]];then
mindex=j;
fi
}
tmp=${arrs[i]}
arrs[i]=${arrs[mindex]}
arrs[mindex]=$tmp
}
echo "result:"
echo ${arrs[@]}

运行结果

please input a number list:
5 9 3 4 7 6
result:
3 4 5 6 7 9

最新文章

  1. 存储程序(2)——MYSQL
  2. 实战手记:让百万级数据瞬间导入SQL Server
  3. 联想 thinkpad fn键关闭,优化使用
  4. HTML练习----注册界面
  5. shell编程基础(4)case 与 function
  6. 设计模式------PROTOTYPE(原型),TEMPLATE(模板)
  7. Effective Java2读书笔记-类和接口(五)
  8. python正则表达式练习篇
  9. Java 抽象工厂模式
  10. highcharts第一篇---简介和使用
  11. 【转】CXF+Spring+Eclipse简明示例
  12. Unable to update index for central
  13. Using variables inside Postman and Collection Runner
  14. Django By Example 总结
  15. X级联动
  16. python--使用队列结构来模拟烫手山芋的游戏
  17. Linux中配置别名
  18. UVA1626 - Brackets sequence(区间DP--括号匹配+递归打印)
  19. js 获取浏览器/网页宽度高度整理
  20. SPL之Iterator和ArrayAccess的结合使用

热门文章

  1. ubuntu使用anaconda安装tensorflow
  2. Python进阶-III 函数装饰器(Wrapper)
  3. Browser cannot find PAC because wpad hostname cannot be resolved
  4. GO 解决使用bee工具,报 bash: bee: command not found
  5. Flask的响应及request属性整理
  6. 【JZOJ100209】【20190705】狂妄之人
  7. python3 获取日期时间
  8. Go:为何带来泛型
  9. TCP、UDP和HTTP区别详解
  10. 备忘Sourcetree配置