Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ColumnList question (sort column)
|
|
|
Re: ColumnList question (sort column) [message #2913 is a reply to message #2898] |
Sat, 29 April 2006 22:58 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
forlano wrote on Sat, 29 April 2006 05:32 | Hello,
I have put my data in a columnlist widget and I would like to see them sorted alphabetically (it does not matter if during the insertion or at the end). The syntax to do it is:
Sort(const ValueOrder& order)
but I was unable fo find an example that shows how to set this argument.
Thank you,
Luigi
|
[/code]
struct ValueOrder {
virtual bool operator()(const Value& a, const Value& b) const = 0;
};
struct StdValueOrder : ValueOrder {
int language;
virtual bool operator()(const Value& a, const Value& b) const;
StdValueOrder(int l = -1);
virtual ~StdValueOrder();
};
struct FnValueOrder : ValueOrder {
int (*fn)(const Value& a, const Value& b);
virtual bool operator()(const Value& a, const Value& b) const;
FnValueOrder(int (*fn)(const Value& a, const Value& b));
virtual ~FnValueOrder();
};
[/code]
Use "StdValueOrder()" in place of ValueOrder if you expect the "normal" ordering and content of columnlist consists of "Std" values (number, String, Date, Time).
list.Sort(StdValueOrder());
If you need something special, you can either create comparison function and use FnValueOrder, or you can derive ValueOrder and provide new operator().
Mirek
|
|
|
Re: ColumnList question (sort column) [message #2916 is a reply to message #2913] |
Sat, 29 April 2006 23:20 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
luzr wrote on Sat, 29 April 2006 22:58 |
list.Sort(StdValueOrder());
|
This was enough to let it to work. The other lines were too complicated to understand for the moment... I've not yet learned the chapter about the operator in the Eckel's book .
Thanks,
Luigi
[Updated on: Sat, 29 April 2006 23:20] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat May 04 14:18:07 CEST 2024
Total time taken to generate the page: 0.02812 seconds
|