# sort_func.hpp File Reference

Functions related to sorting operations. More...

`#include <stdlib.h>`
`#include "math_func.hpp"`
`#include "mem_func.hpp"`

Go to the source code of this file.

## Functions
template<typename T>
static FORCEINLINE void | QSortT (T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
| Type safe qsort().
template<typename T>
static void | GSortT (T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
| Type safe Gnome Sort.

## Detailed Description

Functions related to sorting operations.

Definition in file sort_func.hpp.

## Function Documentation

template<typename T>

static void GSortT | ( | T * | base,
|  | uint | num,
|  | int(CDECL *comparator)(const T *, const T *) | ,
|  | bool | desc = `false` |
| ) |  |  | `[inline, static]`

Type safe Gnome Sort.

This is a slightly modifyied Gnome search. The basic Gnome search trys to sort already sorted list parts. The modification skips these.

Note:
  Use this sort for presorted / regular sorted data.

Parameters:

  | base | Pointer to the first element of the array to be sorted.
  | num | Number of elements in the array pointed by base.
  | comparator | Function that compares two elements.
  | desc | Sort descending.

Definition at line 48 of file sort_func.hpp.

References Swap().

template<typename T>

static FORCEINLINE void QSortT | ( | T * | base,
|  | uint | num,
|  | int(CDECL *comparator)(const T *, const T *) | ,
|  | bool | desc = `false` |
| ) |  |  | `[inline, static]`

Type safe qsort().

Todo:
  replace the normal qsort with this one

Note:
  Use this sort for irregular sorted data.

Parameters:

  | base | Pointer to the first element of the array to be sorted.
  | num | Number of elements in the array pointed by base.
  | comparator | Function that compares two elements.
  | desc | Sort descending.

Definition at line 24 of file sort_func.hpp.

References MemReverseT().