Sha256: d4a461efaf0ac8f6974ba74667a32fb5c540f6351e506c7f27e9e1986621dd22

Contents?: true

Size: 1.02 KB

Versions: 12

Compression:

Stored size: 1.02 KB

Contents

(examples-for sort
  ("sorts a list of numbers"
   (sort '(3 5 4 7 8 2))
   (2 3 4 5 7 8))

  ("sorts a list of syms"
   (sort '(c g d o a p b m e g a z m))
   (a a b c d e g g m m o p z))

  ("sorts a list of strings"
   (sort '("c" "g" "d" "o" "a" "p" "b" "m" "e" "g" "a" "z" "m"))
   ("a" "a" "b" "c" "d" "e" "g" "g" "m" "m" "o" "p" "z")))

(examples-for sort-by
  ("sorts a list of hashes by a specified key"
   (let hh (list { a 1 b 2 } { a 7 b 9 } { a 3 b 1 } { a 2 b 8 })
     (pp (sort-by &a hh)))
   "({ a 1 b 2 } { a 2 b 8 } { a 3 b 1 } { a 7 b 9 })")

  ("sorts a list of strings according to their length"
   (sort-by len
            '("short" "very very very long" "somewhat long" "more medium" "min" "medium"))
   ("min" "short" "medium" "more medium" "somewhat long" "very very very long"))

  ("sort a list of strings according to their length even when some strings have the same length"
   (sort-by len
            '("short" "very long" "sport" "very song" "min" "max"))
   ("max" "min" "sport" "short" "very song" "very long")))

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
nydp-0.2.1 lib/lisp/tests/sort-examples.nydp
nydp-0.2.0 lib/lisp/tests/sort-examples.nydp
nydp-0.1.15 lib/lisp/tests/sort-examples.nydp
nydp-0.1.14 lib/lisp/tests/sort-examples.nydp
nydp-0.1.13.2 lib/lisp/tests/sort-examples.nydp
nydp-0.1.13.1 lib/lisp/tests/sort-examples.nydp
nydp-0.1.13 lib/lisp/tests/sort-examples.nydp
nydp-0.1.12 lib/lisp/tests/sort-examples.nydp
nydp-0.1.11 lib/lisp/tests/sort-examples.nydp
nydp-0.1.10 lib/lisp/tests/sort-examples.nydp
nydp-0.1.9.1 lib/lisp/tests/sort-examples.nydp
nydp-0.1.9 lib/lisp/tests/sort-examples.nydp