Array Sorting

Tristam MacDonald swiftcoder at gmail.com
Wed Jun 20 05:47:37 PDT 2007


Is this an array of integers, or an array of strings containing integer values? I take it it is the latter, since the sort is being performed lexicographically, rather than numerically. In that case, probably the easiest would be to convert your strings to integers to sort them, and convert back to strings afterwards.

You could also, of course, write a custom sort function.

okibi Wrote:

> Hey,
> 
> I was wondering if there is a way to sort three digit numbers.
> 
> Doing an array.sort will result in a sequence such as this:
> 
> 1
> 10
> 2
> 24
> 
> What I want is it to get sorted like this:
> 
> 1
> 2
> 10
> 24
> 
> Is there an easy way to specify this? Putting a 0 in front is not an option.
> 
> Thanks!



More information about the Digitalmars-d-learn mailing list