Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting string-array

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>
like image 921
anuj Avatar asked May 22 '14 12:05

anuj


2 Answers

String[] list = getResources().getStringArray(R.array.Profession); 

Arrays.sort(list);
like image 154
Orhan Obut Avatar answered Oct 21 '22 04:10

Orhan Obut


You can use this to sort your Arrays.

Collections.sort(Your_Array)
like image 26
Emm Jay Avatar answered Oct 21 '22 03:10

Emm Jay