2

I have a SparseArray Key value Pair. The Key will be my ID and I'm sorting the value with separately maintained sort order numbers. But when I put data into SparseArray the key is sorted and sort order are changed according to Key. But i need the values exactly as I put into sort array. How can I

Kavin Prabhu
  • 2,307
  • 2
  • 17
  • 36

2 Answers2

1

I beleive the description of sparse array clearly mentions the difference:

It is intended to be more memory efficient than using a HashMap to map Integers to Objects, both because it avoids auto-boxing keys and its data structure doesn't rely on an extra entry object for each mapping. For further reading: http://developer.android.com/reference/android/util/SparseArray.html

OR

https://mathematica.stackexchange.com/questions/2369/finding-all-elements-within-a-certain-range-in-a-sorted-list

Community
  • 1
  • 1
Rahul Mayani
  • 3,761
  • 4
  • 25
  • 40
-1

SparseArrays iteration over the keys using keyAt(int) with ascending values of the index will return the keys in ascending order, or the values corresponding to the keys in ascending order in the case of valueAt(int).

krunal shah
  • 364
  • 2
  • 14