I have string-array of profession in my values/strings.xml.I want to sort the array in alphabetical order.How can i achieve it.
Strings.Xml
<string-array name="Profession">
<item>Caretaker</item>
<item>Cook</item>
<item>Driver</item>
<item>Governess</item>
<item>HouseKeeper</item>
<item>Maid</item>
<item>Watchman</item>
<item>Washerman</item>
<item>Paper Supplier</item>
<item>Milkman</item>
<item>Electrician</item>
<item>Ration Supplier</item>
<item>Gas Supplier</item>
<item>Volunteer</item>
<item>Nurse</item>
<item>Other</item>
<item>Carpenter</item>
<item>Plumber</item>
<item>Mason</item>
<item>Delivery Boy</item>
<item>Gardner</item>
<item>Janitor</item>
<item>Launderer</item>
<item>Dhobi/Press</item>
<item>Odd Jobs</item>
<item>Vendor</item>
<item>Shopkeeper </item>
</string-array>
String[] list = getResources().getStringArray(R.array.Profession);
Arrays.sort(list);
You can use this to sort your Arrays.
Collections.sort(Your_Array)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With