> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/sort_stability.md).

# Sort stability

Sidef uses the stable merge-sort algorithm for sorting an array.

```ruby
var table = [
  <UK  London>,
  <US  New\ York>,
  <US  Birmingham>,
  <UK  Birmingham>,
]
 
table.sort {|a,b| a[0] <=> b[0] }.each { |col|
    say "#{col[0]} #{col[1]}"
}
```

#### Output:

```
UK London
UK Birmingham
US New York
US Birmingham
```
