Re: EOSortOrdering numerical question
Re: EOSortOrdering numerical question
- Subject: Re: EOSortOrdering numerical question
- From: Chuck Hill <email@hidden>
- Date: Wed, 20 Oct 2004 12:52:24 -0700
At 03:38 PM 20/10/2004 -0400, james o wrote:
>EOSortOrdering order = new EOSortOrdering
>("displayTime",EOSortOrdering.CompareAscending); //or
>CompareCaseIncensitiveAscending
>
>how do i numerically sort numbers in WO? if i use the above code for
>"displayTime" i get the following output?
>
>1
>16
>2
>3
>33
>4
>5
>6
>61
>7
>
>i should see this:
>
No. You _should_ see exactly what you do see. What you _want_ to see is:
>1
>2
>3
>4
>5
>6
>7
>16
>33
>66
>
There is a crucial difference there! You are sorting on a string field and
they collate as characters, not as integers. You can do one of the following:
1. Use a numeric column instead of a String.
2. Left pad the string with spaces so that the rightmost digits line up
3. Create a new comparator that does what you want.
Chuck
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden