![]() | This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||
|
Example inefficient
editWhy 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)
[Untitled]
editWhy does Qsort redirect here? Is there any disambiguation page of Qsort? 202.124.74.82 (talk) 06:34, 6 January 2010 (UTC)
- Which pages did you have in mind for the disambiguation page? - Richfife (talk) 16:27, 6 January 2010 (UTC)
arbitrary objects
editIt 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)
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)
- 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)