I was recently tasked with sorting by Kolmogorov-Smirnov p-values. I can do this inside Perl with the Statistics::R package (http://search.cpan.org/…/Statistics-R-0…/lib/Statistics/R.pm) but this package calls R externally, and is thus extraordinarily slow. I've also found GSL packages, but these don't have the Kolmogorov-Smirnov test available.
I have the source code for the ks.test function inside R, but as I said, this is impractical. How can I translate this to Perl, or C?