Function mergesort_iter

Function Documentation

struct llist_node *mergesort_iter(struct llist_node *list, int (*cmpe)(const void *const e1, const void *const e2), bool_t isdouble)

Sort a linked list using iterative mergesort.

This function sorts a linked list using at iterative implementation of mergesort It has minimal stack/memory requirements, beyond a few local variables. It can be used to sort any singly or doubly linked list. It is assumed that the list has at least 2 items in it.

Parameters:
  • list – The list to sort

  • cmpe – A comparison function for the data managed by each node

  • isdouble – true if the list to be sorted is doubly linked

Returns:

A pointer to the sorted list