Hi guys,
How to use qSort() if the QList contains pointers like this...
QList <
double* > _doubleList;
// this is for simple easyness , you can give QList<employee*>
_doubleList .append( new( 2.22) );
_doubleList .append( new( 1.22) );
_doubleList .append( new( 4.22) );
_doubleList .append( new( 3.22) );
qSort( _doubleList ); // This code will not sort the data properly
QList < double* > _doubleList;
// this is for simple easyness , you can give QList<employee*>
_doubleList .append( new( 2.22) );
_doubleList .append( new( 1.22) );
_doubleList .append( new( 4.22) );
_doubleList .append( new( 3.22) );
qSort( _doubleList ); // This code will not sort the data properly
To copy to clipboard, switch view to plain text mode
while using the above "_doubleList" the data is not sorting .
But if am using the list like this ...
QList <
double > _doubleList;
// this is for simple easyness , you can give QList<employee*>
_doubleList .append( 2.22 );
_doubleList .append( 1.22 );
_doubleList .append( 4.22 );
_doubleList .append( 3.22 );
qSort( _doubleList ); // This code WILL SORT the data properly
QList < double > _doubleList;
// this is for simple easyness , you can give QList<employee*>
_doubleList .append( 2.22 );
_doubleList .append( 1.22 );
_doubleList .append( 4.22 );
_doubleList .append( 3.22 );
qSort( _doubleList ); // This code WILL SORT the data properly
To copy to clipboard, switch view to plain text mode
please tell me how to sort a QList which contains pointers.
thanks in advance
Bookmarks