Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does R use radix sort?

From my understanding, R's order() method uses radix sort by default. This was not always the case (see news), but Matt Dowle made this presentation suggesting change because radix sort empirically performs well.

My question is, why is radix sort better than other sorting algorithms in practice? Wikipedia doesn't make a strong case for radix sort. Also, why do other popular languages/tools like Python and pandas not use radix sort by default, if it is truly the best sorting algorithm?

like image 779
Ben Avatar asked Oct 24 '17 22:10

Ben


1 Answers

As you know, there is not any best sorting algorithm in general case. A solution can be Radix sort is a stable sort. Hence, as in R keeping the order of tie cases could be important, they implemented a stable sort method.

You can find more about the stability here and also in this post.

Another point is, as stability can be important in different situations, you should find the best between stable sort algorithms which come here.

B

  • Block sort
  • Bubble sort
  • Bucket sort

C

  • Cascade merge sort
  • Cocktail shaker sort
  • Counting sort
  • Cubesort

G

  • Gnome sort

I

  • Insertion sort

L

  • Library sort

M

  • Merge sort

O

  • Odd–even sort
  • Oscillating merge sort

P

  • Pigeonhole sort
  • Proxmap sort

R

  • Radix sort

T

  • Timsort
like image 69
OmG Avatar answered Oct 17 '22 08:10

OmG