Recently I faced a question in an interview and I was unable to make logic for this question. I have an array like
[ 1,'a',45,'h',56,'d',2,'t',6,'p' ] . How to sort this array ? Output should be in this manner..
intArray = [1,2,6,45,56]
charArray= ['a','d','h','p','t']
If anybody knows its logic please comment. It would be a great help.
Thanks !
ArrayorArrayList?intArrayand acharArrayfirst, and then sort those two arrays separately. Or, you could create a comparator that primarily sorts on element type and secondarily on value. Then sort the whole thing and split it in two.