Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Sorting problem. Please Help!
Sorting problem. Please Help! [message #27879] |
Mon, 09 August 2010 09:45 |
|
Trouble with Sorting data in GridCtrl. Maybe this bug is not due GridCtrl.
1.During the sorting text column - the number should be sorted as strings. For example, if there are 3 lines -
"3" "1" "123"
- then the string should be sorted in the order
"1" "123" "3",
but actually are in order
- "1" "3" "123".
How do I fix this?
2.If the text column, there are Russian characters, for some reason the sorting algorithm takes this value as a number and get for example this situation:
There are three lines:
"Albert" "Albert Aaaaaaaaaaaaaaaaaaaaa" "Albert Zbiven"
actually they are in order of
"Albert" "Albert Zbiven" "Albert Aaaaaaaaaaaaaaaaaaaaa", although it is clear that this order is incorrect.
For Russian characters even seen an issue where if you sort the letters jump so that about any sort is out. For example last names may go in order
"Èâàíîâ Èâàí", then "Ïåòðîâ Ïåòð" again "Èâàíîâ Ïàâåë" then "Ïåòðîâ Ñåðãåé". That is, it's not a problem right alphabetical order, something deeper, something I do not really understand.
TestCase (compiled from Grid01 of the tutorial) shows both problems. The screenshot can be seen both.
-
Attachment: Shot.png
(Size: 31.69KB, Downloaded 556 times)
-
Attachment: Grid01.zip
(Size: 3.81KB, Downloaded 515 times)
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
|
|
|
|
|
Re: Sorting problem. Please Help! [message #27883 is a reply to message #27879] |
Mon, 09 August 2010 11:10 |
|
I analyzed DefaultLanguageCompare and this function can recognize the number even if it was passed as a string. So when comparing numbers 123 > 3. I know this is incorrect from developer point of view but for user 123 and 3 are numbers not strings. And I think this is correct behavior.
As for second case I cannot reproduce it. The order is correct. In grid I can see "Albert", "Albert Aaaaaaaaaaaaaaaaaaaaa", "Albert Zbiven"
|
|
|
Re: Sorting problem. Please Help! [message #27886 is a reply to message #27883] |
Mon, 09 August 2010 12:40 |
|
"Albert", "Albert Aaaaaaaaaaaaaaaaaaaaa", "Albert Zbiven" - This names only for problem descriptions. Real problem with Russian names. U++ (or GridCtrl) work with Russian strings as with numbers.
(I use Russian values in TestCase.)
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
[Updated on: Mon, 09 August 2010 12:41] Report message to a moderator
|
|
|
|
Re: Sorting problem. Please Help! [message #27889 is a reply to message #27886] |
Mon, 09 August 2010 12:55 |
|
About String Number sorting...
If I use strings "1f" "2f" "3f" "123f" "34f" U++ sorts this as
"1f"
"2f"
"34f"
"123f"
In this case, we can not talk about numbers in a string variable.
I understand that system sorting algorithm - failed, or works in unforeseen circumstances.
So this problem is likely not only GridCtrl. That is, it may appear in other places.
From GridCtrl can solve this problem, relegate sorting in database. How to deal with this in other places - is unclear.
All the same, may be to introduce the sort parameter - numeric data or text?
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: Sorting problem. Please Help! [message #27890 is a reply to message #27888] |
Mon, 09 August 2010 12:58 |
|
unodgs wrote on Mon, 09 August 2010 14:51 | Russian strings are treated as strings (I checked this), however the algorithm used for comparison is not understandable for me (at least now). Maybe Mirek could shed some light at it.
|
Yes this testcase show type of value in 3-d column (3-string).
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
|
|
|
Goto Forum:
Current Time: Fri Mar 29 11:27:55 CET 2024
Total time taken to generate the page: 0.02093 seconds
|