0

Is there any way to order the lines inside of SharedPreferences?

I'm trying to add keys with a number, but they are shown without order.

<string name="Score_3">96</string>
<string name="Score_1">256</string>
<string name="Score_4">26</string>
<string name="Score_2">0</string>

I would like to be shown like this. Is this possible?

<string name="Score_1">256</string>
<string name="Score_2">0</string>
<string name="Score_3">96</string>
<string name="Score_4">26</string>```
Thanks.
  • Please provide your minimal code which *shows values without order*. – hata Apr 25 '20 at 11:29
  • @hata already did in the question – Xavi Segura Ardévol Apr 25 '20 at 11:58
  • They are your data or output (without order and with order) which are to be shown. I mean your Android program which processes and shows those data. – hata Apr 25 '20 at 11:59
  • Once you have loaded them in a List you can sort them easily. https://stackoverflow.com/questions/708698/how-can-i-sort-a-list-alphabetically https://stackoverflow.com/questions/11207640/android-sort-data-retrieved-from-sharedpreferences – einUsername Apr 25 '20 at 13:09

0 Answers0