File indexing completed on 2024-05-12 03:47:54

0001 /*
0002     File                 : nsl_sort.c
0003     Project              : LabPlot
0004     Description          : NSL sorting functions
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2016 Stefan Gerlach <stefan.gerlach@uni.kn>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #include "nsl_sort.h"
0011 #include <stdlib.h>
0012 
0013 int nsl_sort_compare_size_t(const void* a, const void* b) {
0014     size_t _a = *((size_t*)a);
0015     size_t _b = *((size_t*)b);
0016 
0017     /* an easy expression for comparing */
0018     return (_a > _b) - (_a < _b);
0019 }
0020 
0021 void nsl_sort_size_t(size_t array[], const size_t n) {
0022     qsort(array, n, sizeof(size_t), nsl_sort_compare_size_t);
0023 }