我有字典的陣列,它是在一種格式,在iPhone的字典數組中排序浮點數據?
resultsArray = {
id = 1;
name = test;
distance = 11.5;
id = 2;
name = test1;
distance = 0.5;
id = 3;
name = test2;
distance = 2.5;
id = 4;
name = test4;
distance = 1.5;
}
我想使用的距離鍵和我的浮子式距離排序的數組。那麼我怎樣才能排序數組使用距離是在升序?
,所以我期待的結果是這樣,
resultsArray = {
id = 2;
name = test1;
distance = 0.5;
id = 4;
name = test4;
distance = 1.5;
id = 3;
name = test2;
distance = 2.5;
id = 1;
name = test;
distance = 11.5;
}
請幫助我。
謝謝!
感謝我已經嘗試過的答案,但仍然有相同的問題,所以請幫助我 – Rahul
奇怪。我做了一個測試,以確認我的答案,它的工作。發佈您的代碼。 – gschandler