可能性の重複:
How to sort numeric and literal columns in Vimソート数値VIエディタで
私はスレッドIDに基づいて、以下の行をソートする必要があります。私は:!sort -n
を発行すると
Internal thread 0 bound to OS proc set {1}
Internal thread 1 bound to OS proc set {5}
Internal thread 2 bound to OS proc set {9}
Internal thread 10 bound to OS proc set {41}
Internal thread 9 bound to OS proc set {37}
彼らは次のように並べ替えられます:
Internal thread 0 bound to OS proc set {1}
Internal thread 1 bound to OS proc set {5}
Internal thread 10 bound to OS proc set {41}
Internal thread 2 bound to OS proc set {9}
Internal thread 9 bound to OS proc set {37}
しかし、私は彼らがこのようにソートする必要があります。
Internal thread 0 bound to OS proc set {1}
Internal thread 1 bound to OS proc set {5}
Internal thread 2 bound to OS proc set {9}
Internal thread 9 bound to OS proc set {37}
Internal thread 10 bound to OS proc set {41}
あなたの場合、 '%%sort -n -k 3' –
@MichaelBerkowski:ありがとう、それは完璧に動作します。私がそれを受け入れるためにこれを答えとして提供してください。私はオプション 'n'と' 3'を理解しています。しかし、なぜ私は余分な '-k'が必要なのでしょうか? 'n'は数値ソートには不十分です – arunmoezhi
' -k 3'は第3フィールドを明示的にソートします。 – sebnukem