st1tch

11-28-2006, 01:18 PM

I have an array that look like the following

var a:Array = [{Letter:"A", Percentage:"1%"},{Letter:"B", Percentage:"2%"},

{Letter:"C", Percentage:"10%"},

{Letter:"D", Percentage:"11%"},

{Letter:"E", Percentage:"3%"}]

I want to sort this array on Percentage, what i get is 1%, 10%, 11%, 2%, 3%, this is due because the sort function is taking the percentage data as string. I tried to build my own custom sort function but still i cant seem to get it work, i tried to substring the % from the data and sort the rest as number but its not working

So if anyone can help me i would be more than thankful

Regards;

S.

var a:Array = [{Letter:"A", Percentage:"1%"},{Letter:"B", Percentage:"2%"},

{Letter:"C", Percentage:"10%"},

{Letter:"D", Percentage:"11%"},

{Letter:"E", Percentage:"3%"}]

I want to sort this array on Percentage, what i get is 1%, 10%, 11%, 2%, 3%, this is due because the sort function is taking the percentage data as string. I tried to build my own custom sort function but still i cant seem to get it work, i tried to substring the % from the data and sort the rest as number but its not working

So if anyone can help me i would be more than thankful

Regards;

S.