FLTK 1.4.0
numericsort.c File Reference
#include <ctype.h>
#include <stdlib.h>
#include <FL/platform_types.h>
#include <FL/filename.H>

Functions

int fl_casenumericsort (struct dirent **A, struct dirent **B)
 Compares directory entries alphanumerically (case-insensitive). More...
 
int fl_numericsort (struct dirent **A, struct dirent **B)
 Compares directory entries alphanumerically (case-sensitive). More...
 

Function Documentation

◆ fl_casenumericsort()

int fl_casenumericsort ( struct dirent **  A,
struct dirent **  B 
)

Compares directory entries alphanumerically (case-insensitive).

Note
This comparison is not (yet) UTF-8 aware.
Todo:
Make comparison UTF-8 aware.
See also
fl_numericsort()

◆ fl_numericsort()

int fl_numericsort ( struct dirent **  A,
struct dirent **  B 
)

Compares directory entries alphanumerically (case-sensitive).

Numbers are compared without sign, i.e. "-" is not taken as a sign of following numerical values. The following list of files would be in ascending order (examples are ASCII and numbers only for simplicity):

  1. 1zzz.txt
  2. 2xxx.txt
  3. 19uuu.txt
  4. 100aaa.txt
  5. file1z.txt
  6. file5a.txt
  7. file5z.txt
  8. file30z.txt
  9. file200a.txt
  10. temp+5.txt ('+' is lexically lower than '-')
  11. temp-5.txt ('-' is not a sign)
  12. temp-100.txt (100 is bigger than 5, no sign)
Parameters
[in]Afirst directory entry
[in]Bsecond directory entry
Returns
comparison result (-1, 0, or +1)
Return values
-1A < B
0A == B
+1A > B
Note
This comparison is not (yet) UTF-8 aware:
  • UTF-8 characters are compared according to their binary values.
  • Locale settings may influence the result in unexpected ways.
  • The latter is particularly true for fl_casenumericsort(). This may be changed in a future release.
Todo:
Make comparison UTF-8 aware.
See also
fl_casenumericsort()