From: matz@... (Yukihiro Matsumoto) Date: 2000-09-29T08:46:17+09:00 Subject: [ruby-talk:5179] Re: methods w/ ! giving nil Hi, In message "[ruby-talk:5173] Re: methods w/ ! giving nil" on 00/09/28, Davide Marchignoli writes: | |> Actually Ruby does have its own qsort routine in C (in util.c), which |> is compatible with original qsort(3). Only problem left is re-design |> and hack the routine. I'm afraid it's a tough task, for me at least. | |Changing swap does not work since swap can be invoked also for equal |values and it one has to be careful in defining if the list is changed or |not. The only other solution (I can think of) is checking if the array is |already sorted. The check is already present in the ruby_sort code so this |small change does not affect performances. | |In any case, the *average* cost of checking if an array is sorted is a |*small* constant number of comparisons. | |The following patch should do the job: Let me compare this with [ruby-talk:4564]. And could give me a patch in unified diff style next time? matz.