2019-03-29 19:45:44 +01:00
|
|
|
# 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.
|
2017-10-17 22:28:43 +02:00
|
|
|
|
|
|
|
~~~
|
2019-03-29 19:45:44 +01:00
|
|
|
:sort-pair dup-pair lt? &swap if ;
|
|
|
|
:perform-sort sort-pair depth #2 gt? [ &perform-sort dip ] if ;
|
|
|
|
:sort depth &perform-sort times ;
|
2017-10-17 22:28:43 +02:00
|
|
|
~~~
|
|
|
|
|
2019-03-29 19:45:44 +01:00
|
|
|
```
|
|
|
|
#3 #33 #22 #333 #5 sort
|
|
|
|
```
|