Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to sort a vector?
Re: How to sort a vector? [message #37893 is a reply to message #37875] Tue, 20 November 2012 16:02 Go to previous messageGo to previous message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
koldo wrote on Mon, 19 November 2012 16:09

Hello Crydev

AFAIK ArrayCtrl Sort() uses Value comparison that in case of Strings uses DefaultLanguageCompare() function in LangInfo.cpp. However String comparison uses String0::Compare() in AString.hpp.

If you prefer the second, I suppose that you have to create a comparison function like this;

int MyStringCompare(const Value& a, const Value& b) {
	return a.ToString() < b.ToString();
}


and refer to it in Sort:

array.Sort(columnToSort, MyStringCompare);


I have not tested it. Does it work?


I tested this. It did work by meaning of: it works, but it didn't work by meaning of it did what I was expecting.

You are saying that the sorting of strings in the ArrayCtrl is done by using the default language rules for strings and the sorting of a vector by using the operator you provided is done by using standard english rules. Am I correct? If so, I think I would need the language specific way of sorting for my vector.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Is libXi needed ??
Next Topic: To add serialize/xmlize/jsonize functions to EditField and others
Goto Forum:
  


Current Time: Tue Jun 17 05:28:28 CEST 2025

Total time taken to generate the page: 0.04017 seconds