title: How to sort list by Persian alphabet?
body: <p>How can I read <code>testArrray</code> in ul li and sort this list?</p>
  
  <p><code>lis.sort(function(a,b))</code> has English/Arabic/and alphabet support, not Persian alphabet support. Help me please. Thank you</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var alphabets = ["ا", "ب", "پ", "ت", "ث", "ج", "چ", "ح", "خ", "د", "ذ", "ر", "ز", "ژ", "س", "ش", "ص", "ض", "ط", "ظ", "ع", "غ", "ف", "ق",
    "ک", "گ", "ل", "م", "ن", "و", "ه", "ی", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
  ];
  var testArrray = ["ی", "گ", "ژ", "پ"];
  
  var aChar;
  var bChar;
  
  function OrderFunc() {
    testArrray.sort(function(a, b) {
      return CharCompare(a, b, 0);
    });
    document.getElementById("result").innerHTML = testArrray;;
  }
  
  function CharCompare(a, b, index) {
    if (index == a.length || index == b.length)
      return 0;
      
    aChar = alphabets.indexOf(a.toUpperCase().charAt(index));
    bChar = alphabets.indexOf(b.toUpperCase().charAt(index));
    
    if (aChar != bChar)
      return aChar - bChar
    else
      return CharCompare(a, b, index + 1)
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body onload="OrderFunc()"&gt;
    &lt;div id="result"&gt;&lt;/div&gt;
    &lt;ul class="myul"&gt;
      &lt;li&gt;ی&lt;/li&gt;
      &lt;li&gt;پ&lt;/li&gt;
      &lt;li&gt;گ&lt;/li&gt;
      &lt;li&gt;ژ&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>