Ignorable Characters

Characters in the rule before the first '<' are ignorable. They are not considered during the primary sorting. Accents and punctuation are often marked as ignorable, but given a non-ignorable secondary or tertiary weight. For example, the default Java rule starts out with:

  "='\u200B'=\u200C=\u200D=\u200E=\u200F ... 
  ";'\u0020';'\u00A0'..."
  

This completely ignores the first five characters (formatting control), and ignores except for secondary differences the next two characters (spacing characters).

This is why all example rules up till now started with '<' (so that none of the characters would be ignorable).

In the In the notice how the space character was entered using quotes to disambiguate it from insignificant white space. Example of locale sorting notice how the space character was entered using quotes to disambiguate it from insignificant white space. Example of locale sorting

Assume the file "my_loc" has the following data in it:

  $collate_narrow
  
  "; - = ' ' 

  < a, A < b, B < c, C

  < ch, cH, Ch, CH

  < d, D < e, E < f, F

  < g, G < h, H < i, I

  < j, J < k, K < l, L

  < ll, lL, Ll, LL

  < m, M < n, N < o, O

  < p, P < q, Q < r, R

  < s, S < t, T < u, U

  < v, V < w, W < x, X

  < y, Y < z, Z"
  

The program below creates a vector of strings and sorts them both by "binary order" (just using string's operator <), and by the custom rule above using a locale as the sorting key.

  #include <locale>

  #include <algorithm>

  #include <vector>

  #include <string>

  #include <iostream>

  int main()

  {
      std::vector<std::string> v;
      v.push_back("aaaaaaB");
      v.push_back("aaaaaaA");
      v.push_back("AaaaaaB");
      v.push_back("AaaaaaA");
      v.push_back("blackbird");
      v.push_back("black-bird");
      v.push_back("black bird");
      v.push_back("blackbirds");
      v.push_back("acia");
      v.push_back("acha");
     std::ostream_iterator<std::string> out(std::cout, "\n");
     std::cout << "Binary order:\n\n";
     std::sort(v.begin(), v.end());
     std::copy(v.begin(), v.end(), out);
     std::cout << '\n';
     std::locale loc("my_loc");
     std::sort(v.begin(), v.end(), loc);
     std::cout << "Customized order:\n\n";
     std::copy(v.begin(), v.end(), out);
     std::cout << '\n';
  }
  

The output is:

Binary order:

  AaaaaaA
  AaaaaaB
  aaaaaaA
  aaaaaaB
  acha
  acia
  black bird
  black-bird
  blackbird
  blackbirds
  

Customized order:

  aaaaaaA
  AaaaaaA
  aaaaaaB
  AaaaaaB
  acia
  acha
  blackbird
  black-bird
  black bird
  blackbirds