Workspace 6.21.5
Public Member Functions | List of all members
FileNameNaturalLessThan Class Reference

Compares two QFileInfo's "naturally". Numbers will be compared as numbers, strings compared as strings etc. More...

#include <Workspace/Application/LanguageUtils/compare.h>

Public Member Functions

bool operator() (const QFileInfo &left, const QFileInfo &right) const
 

Detailed Description

This is done by generating "keys" for each string, where each key is an array containing the string split into alpha and numeric parts. For example the string: a123-35abc-15 would become [ a, 123, -, 35, abc, -, 15 ].This key can then be compared piece by piece, ensuring the strings are sorted in a natural way, rather than alphabetically (by ASCII).

Member Function Documentation

◆ operator()()

bool operator() ( const QFileInfo &  left,
const QFileInfo &  right 
) const
Parameters
leftThe left operand of the comparison.
rightThe right operand of the comparison.
Returns
true if left is less than right according to "natural" comparison semantics described in the NaturalLessThan class description.