Sort Numbers

Saury g9414002.pccu.edu.tw at gmail.com
Sat Mar 3 19:12:46 UTC 2012


Hi, there. I have a project about a numbers sorting task.
First I chose set `s' as container for unsorted numbers, then
it's sorted after numbers in `s' were dumped into a vector `v'.
Code is listed as blow.

    | v. s. i |
    s: set copy.
    s add: 5. s add: 6. s add: 3. s add: 2. s add: 7. s add:4.
    v: vector copySize: (s size) FillingWith: 0.
    i: 0.
    s do: [| :n | v at: i Put: n. i: i+1 ].
    v

I thought that the set `s' shell give its elements in the order
the same as of those elements coming. But eventually `v' put
those numbers in ascending order.

Does anyone know why it is that?

Best Regards,
-yau






More information about the Self-interest mailing list