hi all,
I have a strange prob to sort my QList with the qSort() function.
the class to be sorted looks like:
#ifndef MYCLASS_H
#define MYCLASS_H
class MyClass{
public:
MyClass(){}
~MyClass{}
bool operator<(const MyClass& a) const {
return getBpCount() < a.getBpCount();
}
const float getBpCount(void) const{return /*some calculated float*/;}
}
#endif
#ifndef MYCLASS_H
#define MYCLASS_H
class MyClass{
public:
MyClass(){}
~MyClass{}
bool operator<(const MyClass& a) const {
return getBpCount() < a.getBpCount();
}
const float getBpCount(void) const{return /*some calculated float*/;}
}
#endif
To copy to clipboard, switch view to plain text mode
in the class, where I use the class above, I do the following:
QList<MyClass*> *list = new QList<MyClass*>;
for(){/*create new MyClasses & add to list*/}
//finally
//checked the listorder here1
qSort(*list);
//and here2
QList<MyClass*> *list = new QList<MyClass*>;
for(){/*create new MyClasses & add to list*/}
//finally
//checked the listorder here1
qSort(*list);
//and here2
To copy to clipboard, switch view to plain text mode
the list should be sorted, but it isn't 
there is some change between here1 & here2 but @ here2 the list isn't oredered in an ascending or descending order, it seems to be random to me
can anybody tell me what I'm missing or doing wrong???
regards
Bookmarks