30 lines
503 B
C++
30 lines
503 B
C++
/* SPDX-License-Identifier: Apache-2.0
|
|
* (c) 2025, Konstantin Demin
|
|
*/
|
|
|
|
#include "sort.hh"
|
|
|
|
#include <cstring>
|
|
|
|
#include "coreutils-sort.hh"
|
|
|
|
int custom_sort(const char * a, const char * b, sort_mode mode)
|
|
{
|
|
switch (mode) {
|
|
case sort_mode::glibc_version_sort:
|
|
return strverscmp(a, b);
|
|
case sort_mode::coreutils_version_sort:
|
|
return coreutils_version_sort(a, b);
|
|
|
|
// not a actual version sort
|
|
|
|
/*
|
|
case sort_mode::simple_sort:
|
|
return strcmp(a, b);
|
|
*/
|
|
|
|
default:
|
|
return strcmp(a, b);
|
|
}
|
|
}
|