Today I thought about using QT to do a quick sort, so I studied it a bit.
Because of the habit, C + + Std::sort, even if it is a C time is also used stdlib.h in the qsort.
Handwriting board
The fast-line of the tablet is actually not difficult, but since the use of C + + after the ACM has rarely been knocked naked.
where C language Stdlib
Features: Sorting using the quick sort routines
Usage: void qsort (void base,int nelem,int width,int (*fcmp) (const void , const void *));
Parameters:
1 array first address to sort
2 number of elements to be sorted in the array
3 space size of each element
4 A pointer to a function that determines the order of the sort
This library function is supported in QT, but I do not use it very much now, and this function does not support the sort of STL.
Then the sort of the < algorithm > in the standard library, which is a C + + in a specific sort of generic data, but written in QT does not recognize the sort, std::sort. In fact, we can understand that string is converted to qstring, so we guess it's qsort.
Usage is the same as sort.
Header: < algorithm> namespace:std
bool capitysort (const Svideochip msvideofirst,const svideochip msvideosecond) {return (Msvideofirst.mi64videocapacity < msvideosecond.mi64videocapacity); } void * videosort (qlist <svideochip >* msvideochiplist) {qSort (Msvideochiplist-> (), Msvideochiplist->end (), Capitysort ); // STD: :sort (Msvideochiplist->begin (), Msvideochiplist-> End (), capitysort ); }
Use quick sort in qt