As we all have seen, an alpha sort does not understand NCP100 as "NCP-
one-hundred", it sees it as N-C-P-One-Zero-Zero, which comes before N-
C-P-Six-anything.
You could split the file name into alpha and numeric parts. Add
leading zeros to the numeric part then alpha sort:
NCP001
NCP002
NCP005
NCP100
NCP067
NCP068
will then sort alphabetically as
NCP001
NCP002
NCP005
NCP067
NCP068
NCP100
Finally, revert back to the original file names for the user display:
NCP01
NCP02
NCP05
NCP67
NCP68
NCP100
gary
On Oct 24, 2006, at 4:37 PM, Colin Scarrott wrote:
Yes, you have hit the nail on the head there, I've just realise
that the sort is correct and my problem is not the same as I stated
in my first post.
If anyone can answer this or think of a work around it would be
greatly appreciated.
Colin
Your sort looks correct to me. The sorting code is working, so
the question you should ask is "why is "NCP100" <= NCP67"?
Charles Yeomans
On Oct 24, 2006, at 7:11 PM, Colin Scarrott wrote:
Hi,
I have the same problem when sorting a single array, using 2006r4.
For example the values are read in from a database into an array
array.sort is then applied
sorted output is as follows
NCP01
NCP02
...
NCP05
NCP100
NCP67
NCP68
shouldn't the NCP100 be at the bottom of the list?
Hope someone can help
Thanks
Colin
----- Original Message ----- From: "Tim Hare" <[EMAIL PROTECTED]>
To: "REALbasic NUG" <[email protected]>
Sent: Tuesday, October 24, 2006 7:05 AM
Subject: RE: Array.Sort order confusion
I could not reproduce this on 2006r4.
dim myArray()
myArray.Append "D1"
myArray.Append "S13"
...
myArray.Append "S8"
myArray.Sort
Gives the correct result: D1, D2, S1, S10, S11, ...
Tim
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Tim
Jones
Sent: Monday, October 23, 2006 4:54 PM
To: REALbasic NUG
Subject: Re: Array.Sort order confusion
On Oct 23, 2006, at 4:13 PM, Charles Yeomans wrote:
> I can't reproduce this using r3.
Mine was in R4 ... and I didn't recall this happening previously.
After working through this, I realized that the opportunity
for up to
9,999 iterations of each letter variant can occur, so I've changed
the tool that produces the output to provide the numeric component
with leading 0's.
I will put together an example later this evening.
Tim
--
Tim Jones [EMAIL PROTECTED]
>
> Charles Yeomans
> On Oct 23, 2006, at 6:40 PM, Tim Jones wrote:
>
>> Hi Folks,
>>
>> I've an array that will contain a list of values that consist
of a
>> letter and then a number (non-zero padded). The order the
>> elements are received is random. For example:
>>
>> D1
>> S13
>> S1
>> S2
>> S12
>> S10
>> S11
>> S3
>> S4
>> D2
>> S14
>> S15
>> S5
>> S9
>> S7
>> S6
>> S8
>>
>> Given that list order, I issue the array.sort and expect
something
>> that looks like this:
>>
>> D1
>> D2
>> S1
>> S10
>> S11
>> S12
>> S13
>> S14
>> S15
>> S2
>> S3
>> S4
>> S5
>> S6
>> S7
>> S8
>> S9
>>
>> However, the S1 is coming AFTER the S15 in the actual sort (in
>> this example).
>>
>> D1
>> D2
>> S10
>> S11
>> S12
>> S13
>> S14
>> S15
>> S1
>> S2
>> S3
>> S4
>> S5
>> S6
>> S7
>> S8
>> S9
>>
>> In all of my other sorts, S1 is less than S10
>>
>> Is this a bug, or is my expectation of ascending sorts somehow
>> misguided?
>>
>> Tim
>> --
>> Tim Jones [EMAIL PROTECTED]
>>
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives of this list here:
>> <http://support.realsoftware.com/listarchives/lists.html>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.9/490 - Release Date:
20/10/2006
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.9/490 - Release Date:
20/10/2006
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>