Sorting

Sorting Utilities. More...

Typedefs

typedef int() gos_sort_compare_callback_t (const void *lhs, const void *rhs)
Callback function for comparing an two items while sorting. More...

Functions

void gos_bubble_sort_ptr_list (void *base, size_t num, gos_sort_compare_callback_t callback)
Sort array of pointers based on given comparison function.
void gos_bubble_sort_linked_list (void *linked_list_ptr, int next_offset, gos_sort_compare_callback_t callback)
Sort linked list based on given comparison function.

Detailed Description

Sorting Utilities.

Typedef Documentation

gos_sort_compare_callback_t

typedef int() gos_sort_compare_callback_t(const void *lhs, const void *rhs)

Callback function for comparing an two items while sorting.

Taking two pointers as arguments: the first is always key, and the second points to an element of the array (both type-casted to const void*).

The function shall return (in a stable and transitive manner):

  • <0 The element pointed to by `lhs` goes before the element pointed to by `rhs`
  • 0 The element pointed to by `lhs` is equivalent to the element pointed to by `rhs`
  • >0 The element pointed to by lhs goes after the element pointed to by rhs