848ba7303b
FossilOrigin-Name: b5feea667d30aac255d1cfca61fed355d438d2ce6021677f1e53af6302b15eee
14 lines
338 B
Text
14 lines
338 B
Text
# Sorting Numbers on the Stack
|
|
|
|
This is a recursive approach to sorting values on the stack. I
|
|
won't try to claim that this is efficient, but it works.
|
|
|
|
~~~
|
|
:sort-pair dup-pair lt? &swap if ;
|
|
:perform-sort sort-pair depth #2 gt? [ &perform-sort dip ] if ;
|
|
:sort depth &perform-sort times ;
|
|
~~~
|
|
|
|
```
|
|
#3 #33 #22 #333 #5 sort
|
|
```
|