Skip to content

Latest commit

 

History

History
66 lines (31 loc) · 1.62 KB

sort.md

File metadata and controls

66 lines (31 loc) · 1.62 KB

Module 0x2::sort

Utility functions for sorting vector.

Function quick_sort

Sorts a vector using quick sort algorithm.

public fun quick_sort<T>(data: &mut vector<T>)

Function sort

Sorts a vector, returning a new vector with the sorted elements. The sort algorithm used is quick sort, it maybe changed in the future.

public fun sort<T>(data: &mut vector<T>)

Function sort_by_cmp

Sorts a vector using a custom comparison function. The comparison function should return true if the first element is greater than the second.

public fun sort_by_cmp<T>(data: &mut vector<T>, cmp: |(&T, &T)|bool)

Function sort_by_key

Sorts a vector using a custom key function.

public fun sort_by_key<T, K>(data: &mut vector<T>, key: |&T|&K)