> 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/sorting-algorithms/comb_sort.md).

# Comb sort

```ruby
func comb_sort(arr) {
    var gap = arr.len
    var swaps = true
    while (gap > 1 || swaps) {
        gap.div!(1.25).int! if (gap > 1)
        swaps = false
        for i in ^(arr.len - gap) {
            if (arr[i] > arr[i+gap]) {
                arr[i, i+gap] = arr[i+gap, i]
                swaps = true
            }
        }
    }
    return arr
}
```
