Sort stability: Difference between revisions
Content added Content deleted
(Added BBC BASIC) |
|||
Line 590: | Line 590: | ||
# e h j n q s u x z a b c d f g i k l m o p r t v w y |
# e h j n q s u x z a b c d f g i k l m o p r t v w y |
||
# 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 |
# 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 |
||
</lang> |
|||
=={{header|Racket}}== |
|||
Racket comes with a standard <tt>sort</tt> function, which is documented [[http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._sort%29%29 here]]. It is documented as stable. |
|||
<lang Racket> |
|||
#lang racket |
|||
(sort '(("UK" "London") |
|||
("US" "New York") |
|||
("US" "Birmingham") |
|||
("UK" "Birmingham")) |
|||
string<? #:key first) |
|||
;; -> (("UK" "London") ("UK" "Birmingham") |
|||
;; ("US" "New York") ("US" "Birmingham")) |
|||
(sort '(("UK" "London") |
|||
("US" "New York") |
|||
("US" "Birmingham") |
|||
("UK" "Birmingham")) |
|||
string<? #:key second) |
|||
;; -> '(("US" "Birmingham") ("UK" "Birmingham") |
|||
;; ("UK" "London") ("US" "New York")) |
|||
</lang> |
</lang> |
||