I don't know Ruby, but python has an ord () function that translates a special Unicode character to its Unicode code point. For example,
>>> a = u'ل'
>>> ord(a)
0: 1604
>>> b = u'ع'
>>> ord(b)
1: 1593
Look for something similar in Ruby. I assume that Arabic characters are listed in Unicode in alphabetical order.