开发者

Linux Sort command

I would like to know which sorting algorithm the linux SORT command uses开发者_JAVA技巧?


mergesort

It1 uses mergesort rather than quicksort or heapsort for two reasons:

  • mergesort is a stable sort and typically the efficient quicksort implementations are not
  • while it may do more swaps or moves it does fewer comparisons and so tends to work better with text input

1. Linux distros are free to choose their own sort utility but I imagine virtually all use GNU sort so I have described that.


An External R-Way merge sort according to Algorithm details of UNIX Sort Command. Found via this stackoverflow question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜