Get Time
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Tutorial - sorting libraries - custom data type - object oriented language not required | Reply
The tutorial seems to imply that the sorting libraries for non object oriented languages can't handle custom data types, but C's qsort() can sort an array of just about any type, using a pointer to the array, the number of elements, the size of an element, and a pointer to a compare function. C++ std::sort, std::stable_sort, are similar, using a beginning and ending iterator, and an optional pointer to function (or a lambda function or a function operator or overriding of compare operators) for the compare. C++ std::list::sort also has an optional pointer to function for the compare. All of these sorting library functions can work with custom data types.