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 » ArrayCtrl, HeaderCtrl & GridCtrl » Sorting problem. Please Help!
Sorting problem. Please Help! [message #27879] Mon, 09 August 2010 09:45 Go to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 736
Registered: January 2008
Location: Moscow, Russia
Contributor

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.

index.php?t=getfile&id=2710&private=0
  • Attachment: Shot.png
    (Size: 31.69KB, Downloaded 341 times)
  • Attachment: Grid01.zip
    (Size: 3.81KB, Downloaded 377 times)


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Sorting problem. Please Help! [message #27881 is a reply to message #27879] Mon, 09 August 2010 10:16 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

The problem lies in StdValueCompare function which uses DefaultLanguageCompare. I will take a look at it later.

[Updated on: Mon, 09 August 2010 10:16]

Report message to a moderator

Re: Sorting problem. Please Help! [message #27882 is a reply to message #27881] Mon, 09 August 2010 10:46 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 736
Registered: January 2008
Location: Moscow, Russia
Contributor

But Numbers in string columns is different problem. (Despite this, I hope to help).

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 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

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 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 736
Registered: January 2008
Location: Moscow, Russia
Contributor

"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 #27888 is a reply to message #27886] Mon, 09 August 2010 12:51 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

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.
Re: Sorting problem. Please Help! [message #27889 is a reply to message #27886] Mon, 09 August 2010 12:55 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 736
Registered: January 2008
Location: Moscow, Russia
Contributor

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 Go to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 736
Registered: January 2008
Location: Moscow, Russia
Contributor

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 );
}
Previous Topic: DropGrid and Background Colors
Next Topic: GridCtrl::Clear() doesn't take into account SetFixedRows(2)
Goto Forum:
  


Current Time: Thu Nov 21 09:17:42 CET 2019

Total time taken to generate the page: 0.00867 seconds