| Version: 3.2.8

Classes | Functions
arrstr.h File Reference

## Classes
class | wxArrayString
| wxArrayString is an efficient container for storing wxString objects. More...
class | wxSortedArrayString
| wxSortedArrayString is an efficient container for storing wxString objects which always keeps the strings in alphabetical order. More...

## Functions
int | wxStringSortAscending (const wxString &s1, const wxString &s2)
| Comparison function comparing strings in alphabetical order. More...
int | wxStringSortDescending (const wxString &s1, const wxString &s2)
| Comparison function comparing strings in reverse alphabetical order. More...
int | wxDictionaryStringSortAscending (const wxString &s1, const wxString &s2)
| Comparison function comparing strings in dictionary order. More...
int | wxDictionaryStringSortDescending (const wxString &s1, const wxString &s2)
| Comparison function comparing strings in reverse dictionary order. More...
int | wxNaturalStringSortAscending (const wxString &s1, const wxString &s2)
| Comparison function comparing strings in natural order. More...
int | wxNaturalStringSortDescending (const wxString &s1, const wxString &s2)
| Comparison function comparing strings in reverse natural order. More...
int | wxCmpNatural (const wxString &s1, const wxString &s2)
| This function compares strings using case-insensitive collation and additionally, numbers within strings are recognised and compared numerically, rather than alphabetically. More...
int | wxCmpNaturalGeneric (const wxString &s1, const wxString &s2)
| This is wxWidgets' own implementation of the natural sort comparison function. More...
wxArrayString | wxSplit (const wxString &str, const wxChar sep, const wxChar escape='\\')
| Splits the given wxString object using the separator sep and returns the result as a wxArrayString. More...
wxString | wxJoin (const wxArrayString &arr, const wxChar sep, const wxChar escape='\\')
| Concatenate all lines of the given wxArrayString object using the separator sep and returns the result as a wxString. More...

## Function Documentation

## ◆ wxCmpNatural()

int wxCmpNatural | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

This function compares strings using case-insensitive collation and additionally, numbers within strings are recognised and compared numerically, rather than alphabetically.

When used for sorting, the result is that e.g. file names containing numbers are sorted in a natural way.

For example, sorting with a simple string comparison results in:

- file1.txt
- file10.txt
- file100.txt
- file2.txt
- file20.txt
- file3.txt

But sorting the same strings in natural sort order results in:

- file1.txt
- file2.txt
- file3.txt
- file10.txt
- file20.txt
- file100.txt

wxCmpNatural() uses an OS native natural sort function when available (currently only under Microsoft Windows), wxCmpNaturalGeneric() otherwise.

Be aware that OS native implementations might differ from each other, and might change behaviour from release to release.

See also
  wxNaturalStringSortAscending(), wxNaturalStringSortDescending()

Since
  3.1.4

## ◆ wxCmpNaturalGeneric()

int wxCmpNaturalGeneric | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

This is wxWidgets' own implementation of the natural sort comparison function.

See also
  wxCmpNatural()

Since
  3.1.4

## ◆ wxDictionaryStringSortAscending()

int wxDictionaryStringSortAscending | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

Comparison function comparing strings in dictionary order.

The "dictionary order" differs from the alphabetical order in that the strings differing not only in case are compared case-insensitively to ensure that "Aa" comes before "AB" in the sorted array, unlike with wxStringSortAscending().

This function can be used with wxSortedArrayString::Sort() or passed as an argument to wxSortedArrayString constructor.

See also
  wxDictionaryStringSortDescending(), wxStringSortAscending(), wxNaturalStringSortAscending()

Since
  3.1.0

## ◆ wxDictionaryStringSortDescending()

int wxDictionaryStringSortDescending | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

Comparison function comparing strings in reverse dictionary order.

See wxDictionaryStringSortAscending() for the dictionary sort description.

See also
  wxDictionaryStringSortAscending(), wxStringSortDescending(), wxNaturalStringSortDescending()

Since
  3.1.0

## ◆ wxNaturalStringSortAscending()

int wxNaturalStringSortAscending | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

Comparison function comparing strings in natural order.

This function can be used with wxSortedArrayString::Sort() or passed as an argument to wxSortedArrayString constructor.

See wxCmpNatural() for more information about how natural sort order is implemented.

See also
  wxNaturalStringSortDescending(), wxStringSortAscending(), wxDictionaryStringSortAscending()

Since
  3.1.4

## ◆ wxNaturalStringSortDescending()

int wxNaturalStringSortDescending | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

Comparison function comparing strings in reverse natural order.

This function can be used with wxSortedArrayString::Sort() or passed as an argument to wxSortedArrayString constructor.

See wxCmpNatural() for more information about how natural sort order is implemented.

See also
  wxNaturalStringSortAscending(), wxStringSortDescending(), wxDictionaryStringSortDescending()

Since
  3.1.4

## ◆ wxStringSortAscending()

int wxStringSortAscending | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

Comparison function comparing strings in alphabetical order.

This function can be used with wxSortedArrayString::Sort() or passed as an argument to wxSortedArrayString constructor.

See also
  wxStringSortDescending(), wxDictionaryStringSortAscending(), wxNaturalStringSortAscending()

Since
  3.1.0

## ◆ wxStringSortDescending()

int wxStringSortDescending | ( | const wxString & | s1,
|  | const wxString & | s2
| ) |  |

Comparison function comparing strings in reverse alphabetical order.

This function can be used with wxSortedArrayString::Sort() or passed as an argument to wxSortedArrayString constructor.

See also
  wxStringSortAscending(), wxDictionaryStringSortDescending(), wxNaturalStringSortDescending()

Since
  3.1.0