awk中的冒泡排序

算法中经典的排序方式,今也用awk来实现下,代码如下:

BEGIN { count=0}
{arrary[count]=$1
  count++
  }
END{
   for(j=count-1;i>-1;i--)  {
       for(j=0;j<i;j++)
              if(array[j]>array[j+1]{
                          temp=array[j+1]
                          array[j+1]=array[j]
                          array[j]=temp
                          }
                          }
              for(i=0;i<count;i++)
              print array[i]
              }
原文地址:https://www.cnblogs.com/landhu/p/4962570.html