Jump to content

Talk:qsort

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia


Example inefficient

[edit]

Why are you promoting such an inefficient example? What about simply returning x-y?

Or remove the example, wikipedia isn't for learning programming? — Preceding unsigned comment added by 81.16.107.110 (talk) 08:07, 22 April 2017 (UTC)[reply]

[Untitled]

[edit]

Why does Qsort redirect here? Is there any disambiguation page of Qsort? 202.124.74.82 (talk) 06:34, 6 January 2010 (UTC)[reply]

Which pages did you have in mind for the disambiguation page? - Richfife (talk) 16:27, 6 January 2010 (UTC)[reply]

arbitrary objects

[edit]

It doesn't make sense to sort "arbitrary objects" since they don't have a natural ordering. The actual requirement is a set of objects with a strict weak ordering, but I don't know what to cite for that. McKay (talk) 07:00, 20 January 2014 (UTC)[reply]

qsort can sort arbitrary objects, as long as they have fixed size (or are addressed through pointers), because the ordering is entirely decoupled from the objects. It's the comparison function that must fulfill the axioms of a total ordering (C11 Standard, §7.22.5). QVVERTYVS (hm?) 13:25, 22 April 2014 (UTC)[reply]
I'm looking at a slightly later draft but I assume this part hasn't changed. I don't think it is intended to mean what a mathematical reader will understand from the words there. In 7.22.5.2 it says "If two elements compare as equal, their order in the resulting sorted array is unspecified.", but in a total ordered set elements are only equal to themselves. Here the intention is to allow two non-identical elements to compare equal (for example the comparison function can compare a key field in each object and ignore the rest of the objects). An order which is like a total order except extra equalities are allowed is a "strict weak ordering", but I'm not suggesting we use that term that since nobody will understand it. McKay (talk) 06:33, 23 April 2014 (UTC)[reply]