Skip to content

Commit

Permalink
More on sorting. Fix #33
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Jan 9, 2019
1 parent b8965af commit 3d62532
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1808,13 +1808,37 @@ x.reverse()
<tr><td markdown="1">

```python
# Lexical sort by string value
# e.g. [1, 10, 2]
x.sort(key = lambda item: str(item))
```

</td><td markdown="1">

```coffeescript
x.sort() # sort by string value
# Lexical sort by string value
# e.g. [1, 10, 2]
x.sort()
```

</td></tr>
<tr><td markdown="1">

```python
# Sort by numeric value
# e.g. [1, 2, 10]
x.sort(key = lambda item: float(item))
```

</td><td markdown="1">

```coffeescript
# Sort by numeric value
# e.g. [1, 2, 10]
x.sort (x,y) -> x-y
# or, especially for stable sort:
_ = require 'underscore' #or lodash
x = _.sortBy x
```

</td></tr>
Expand Down

0 comments on commit 3d62532

Please sign in to comment.