How did ferret sort by the column?

Consider that if i have a column and the type is int or date
then i pass the :sort field with it i must sort by the value

but if a column which type is string and i set the :sort as it
how did ferret sort by it?
seems it is sort by the first letter of this column according to the
result

i read the source code but stopped in the c code,because i am not
familiar with it and it is complex…

so can anybody give me the answer?
hope i have describe this question clearly
I want to know the mechanism
thank you