coderodde coderodde - 7 months ago 21
Perl Question

In Perl source code, where can I find the implementation of the sort routine?

I would like to experiment with Perl by modifying the actual sort routine.
I did

grep
over the source trying to find some files with name patterns mentioning
sort
, yet did not find anything relevant.

Could anyone of you tell in what file the sort implementation resides?

Answer

I went to https://github.com/Perl/perl5/search?q=sort.

The first search hit was sort.pm, which looked like a good hint. Since that module does not define the search itself, I looked there for keywords that would help me along the way. I chose _quicksort and _mergesort.

https://github.com/Perl/perl5/search?q=_quicksort didn’t show any relevant results, so I tried just quicksort.

That gave me pp_sort.c, and there you go. Almost 200 lines full of sorting.