[Newbies] Sorting

Bert Freudenberg bert at freudenbergs.de
Wed May 16 18:06:44 UTC 2007


On May 16, 2007, at 19:10 , Chris Cunnington wrote:

> Hi Squeakers,
>
> I have a string: 'Hello'.
>
> To reverse the letters I write:
>
>  a := 'Hello' reverse.
>
> And I get 'olleH'.
>
> How do I sort the letters alphabetically? So I get 'eHllo'?
>
>  a := 'Hello' sortBy: [:x :y | a < b ]
>
> What parameter do you use to sort the letters? Do you have to  
> convert them
> to a number, an Ascii or Unicode number first, and then sort those  
> numbers?

'Hello' sort: [:a :b | a asUppercase < b asUppercase]


- Bert -




More information about the Beginners mailing list