Scortch/sort.c
///	Insertion merge sort that honors natural ascending and descending series in the array
Insertion merge sort that honors natural ascending and descending series in the array
Insertion merge sort that honors natural ascending and descending series in the array
void seriesMergeSort(void *array, size_t count, size_t size, void *buffer, size_t space, struct SortingStatistics *statistics, Compare compare, void *context) {
	if ( count < 2 ) {
		return;
	}
	size_t length, sorted = 0;
	size_t minimum = count < 64 ? count / 2 : 32;
	while ( sorted < count ) {
		length = seriesMergeSeek(array + sorted * size, count - sorted, size, minimum, buffer, space, statistics, compare, context);
		if ( sorted > 0 ) {
			mergeSorted(array, sorted + length, sorted, size, buffer, space, statistics, compare, context);
		}
		sorted += length;
		minimum = count - sorted < sorted ? count - sorted : sorted;
	}
}
void seriesMergeSort ( void * array , size_t count , size_t size , void * buffer , size_t space , struct SortingStatistics * statistics , Compare compare , void * context ) { if ( count < 2 ) { return ; } size_t length , sorted = 0 ; size_t minimum = count < 64 ? count / 2 : 32 ; while ( sorted < count ) { length = seriesMergeSeek ( array + sorted * size , count - sorted , size , minimum , buffer , space , statistics , compare , context ) ; if ( sorted > 0 ) { mergeSorted ( array , sorted + length , sorted , size , buffer , space , statistics , compare , context ) ; } sorted += length ; minimum = count - sorted < sorted ? count - sorted : sorted ; } }
Insertion merge sort that honors natural ascending and descending series in the array
Insertion merge sort that honors natural ascending and descending series in the array