0

I have array of objects, each object represents one row. each row(Object ) has different properties like property_name,property_no,Property_desc. I want to sort this array as per the property_name and i want to make it generic so that any array can be passed to comparator and it will sort it. Something like comparator using reflection. Is there any way to do this?

Ganesh
  • 103
  • 10
  • possible duplicate of [Sort ArrayList of custom Objects by property](http://stackoverflow.com/questions/2784514/sort-arraylist-of-custom-objects-by-property) – VLEFF Jul 09 '15 at 08:20
  • Its for simple array not Arraylist and here at run time i want to decide on which property sorting should be done – Ganesh Jul 09 '15 at 08:23
  • Can you elaborate your question more? Since you already know about `Comparator`, why can't you use it and `Arrays.sort()` method? And why do you need reflection? – Codebender Jul 09 '15 at 08:23
  • Arrays.asList(yourArray) and so on... – VLEFF Jul 09 '15 at 08:29
  • I want to sort this array on any property provided at run time. And i stucked there dont know how to sort the array depend on the property provided at run time. Any small example will help here! – Ganesh Jul 09 '15 at 13:01

0 Answers0