Home  >  Q&A  >  body text

linux - Windows下的sort命令如何按值排序?

大家知道在Linux下,我们在进行排序时可以用sort -n来按照key的数值进行排序而不是字符串值排序,那么在Windows下面有类似sort -n的指令吗,只知道Windows下的sort /r等同于Linux的sort -r.

巴扎黑巴扎黑2742 days ago782

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 13:53:56

    Although it seems that my answer is too late, I still give you a similar method that you may have found.
    You can use the sort-Object command in powershell to achieve this purpose.

    λ type a.txt
    1
    10
    2
    3
    5
    8
    90
    11

    After using type a.txt | sort-object -property {$_ -as [int]}:

    λ type a.txt | sort-object -property {$_ -as [int]}
    1
    2
    3
    5
    8
    10
    11
    90

    reply
    0
  • Cancelreply