<<well if its only first name and last name its easy to do using collections
but the problem is i have four arrrays first name, last name, ssn and wages
As Claus has mentioned I cant use Array.sort for each array coz of data integrity>>
What you really have is a 2 dimensionaly array of Objects (i.e. Object[][]). The FormattedDataSet example I pointed you to converts a ResultSet into Object[][] and sorts it with very few lines of code for ANY ResultSet. I have a class called the ArrayComparator that does this behind the scenes. Javadocs and other examples are at
http://www.fdsapi.com. It has a number of signatures that follow.
[code]
Object[][] data=...;
// sort data in array by column 0 in descending order.
ArrayComparator.sort(data, 0, "desc");
// Sort by multiple columns. Much like the SQL 'order by' clause with multiple columns.
ArrayComparator ac=new ArrayComparator();
ac.addSortCol(0,"asc"); // sort by column 0 in ascending order first
ac.addSortCol(1,"desc"); // then by column 1 in descending order
ac.addSortCol(2,"asc"); // then by column 2 in ascending order
ac.sort(array); // note ac can be used to sort as many arrays as needed after it has been created.
//You can combine the ResultSetConverter (a thin wrapper for a ResultSet that converts the ResultSet into Object[][]
ResultSetConverter rsc=new ResultSetConverter(resultSet);
Object[][] resultSetData=rsc.getResultSet();
// Sort the data in the ResultSet by col 3 (i.e. arrays start at 0) in ascending order
ArrayComparator.sort(resultSetData, 2, "asc");
[code]
If you use the FormattedDataSet getSortedText code you can do exactly what you want with a couple lines of code.