title: How to write custom lexicographical comparator c++
body: <p>Lexicographical comparison means </p>
  
  <p>if we have  strings "cat" "apple" "dog" "algorithms" after they are lexicographically compared with each other, they are arranged in dictionary order 
  like following</p>
  
  <blockquote>
    <p>algorithms ,  apple  ,  cat ,   dog</p>
  </blockquote>
  
  <p>I have written following comparator for sorting these strings in lexicographical order.</p>
  
  <pre><code>inline bool leq(int a1, int a2, int b1, int b2)
  {
      return (a1 &lt; b1 || a1 == b1 &amp;&amp; a2 &lt;= b2);
  }
  
  inline bool leq(int a1, int a2, int a3, int b1, int b2, int b3)
  {
      return(a1 &lt; b1 || a1 == b1 &amp;&amp; leq(a2, a3, b2, b3));
  }
  </code></pre>
  
  <p>Now I am  trying to introduce two additional symbols not belonging to alphabet set like 
  "%" and "&amp;" such that while sorting the strings(alphabet set)  "%" should be considered as smaller than all alphabets and "&amp;" should be considered as larger than all alphabets that is </p>
  
  <p>if I have </p>
  
  <p>" apple% " and "apple&amp;"  then apple% should be considered smaller than apple&amp;</p>
  
  <p>Can someone suggest me how to write this in c++. thank you  </p>