samedi 28 mars 2015

Sorting an array (Object[]) consisting of integers and strings - Java



I have and array of type Object[], containing integers and strings (single letters).



Object[] myArray = {(String) "U", (String) "U", (int) 2, (String) "X", (int) 4, (String) "U"};


What my question is, is there a simple way to sort this array, firstly by ints before strings and secondly by ints in numerical ascending order and string in alphabetical order? I was looking for something similar to the Arrays.sort method, but i don't think it will be that simple.


Thank you




Aucun commentaire:

Enregistrer un commentaire