All, I have following data in my vector... After selecting the data from database, the result show in web page....... Emp Code, Emp Name, Emp Telephone, Emp Address....etc If I want the user to select the sorting attribute.... i.e. Click the Emp Code in web page, and the sorting order become Emp Code? I have different attribute type for the vector. Thanks for any help!!!
Author and all-around good cowpoke
posted 14 years ago
You can sort a Vector arbitrarily using static methods in the java.util.Collections class (SDK 1.2 and later). Look at the sort method that takes a List and a Comparator. Since Vector implements List, you can plug it right in. To change the sorting you use a different Comparator customized for your data. Actually you should use an ArrayList instead of Vector. Bill