Re:Crystal 0.28.0 Released
by silly_giraffe on Thursday April 18, 2019 @10:49PM
(#19696705)
>same stuff within the standard library, like list.sort() and sorted(list)
Those have different use cases. `sorted` is for situations where you would use a list comprehension and immediately consume the result vs `.sort` where you need the iterable sorted for future use.
As a quick scribble, you can do something like the following to sort random numbers in a single line:
result = sorted(random.random() for x in range(10))
Those have different use cases. `sorted` is for situations where you would use a list comprehension and immediately consume the result vs `.sort` where you need the iterable sorted for future use.
As a quick scribble, you can do something like the following to sort random numbers in a single line:
From your Medium post: Only the `sorted_builtin` function returns the array, `list_sort` returns None. The `list_sort` function would have to become: Edit: goofed the formatting