Sorting Issues. Equation field does not work with sorting

The builder and api does not sort equation fields which are outputted as number. I tried using make and calling top 5 colors which have the highest order but it sorted the order quantity (an equation field which has some if conditions) in some different way. 900 came as top before 8000 just because first digit 9 is greater than 8. I have tried in other tables also. I cannot run inventory scenarios in make because it does not sort propery. Has anybody faced this issue?
I can sort the same field on the page which has the data table and it sorts out properly.