Which algorithm does Ruby's sort method use?

前端 未结 1 857
别跟我提以往
别跟我提以往 2020-12-13 12:55

When I sort an Array using the native sort method, which algorithm does Ruby use?

Is it data-dependant, i.e., if the data is small it uses X algorithm

相关标签:
1条回答
  • 2020-12-13 13:22

    Look here: http://www.igvita.com/2009/03/26/ruby-algorithms-sorting-trie-heaps/

    It does natively use quicksort however, which is n log n complexity on average.

    0 讨论(0)
提交回复
热议问题