Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 24725 invoked from network); 4 Aug 2009 15:40:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Aug 2009 15:40:35 -0000 Received: (qmail 76354 invoked by uid 500); 4 Aug 2009 15:40:39 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 76240 invoked by uid 500); 4 Aug 2009 15:40:39 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 76230 invoked by uid 99); 4 Aug 2009 15:40:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2009 15:40:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2009 15:40:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id DB824234C046 for ; Tue, 4 Aug 2009 08:40:14 -0700 (PDT) Message-ID: <754953715.1249400414898.JavaMail.jira@brutus> Date: Tue, 4 Aug 2009 08:40:14 -0700 (PDT) From: "Niall Pemberton (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (BEANUTILS-352) Sorting the collection based on bean property in "CollectionUtils" In-Reply-To: <520781047.1244900227414.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/BEANUTILS-352?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Niall Pemberton updated BEANUTILS-352: -------------------------------------- Fix Version/s: LATER THAN 1.8.1 > Sorting the collection based on bean property in "CollectionUtils" > ------------------------------------------------------------------ > > Key: BEANUTILS-352 > URL: https://issues.apache.org/jira/browse/BEANUTILS-352 > Project: Commons BeanUtils > Issue Type: Improvement > Components: Bean-Collections > Environment: JDK 1.5 and above , Apache Collections > Reporter: Ganesh Gowtham > Priority: Minor > Fix For: LATER THAN 1.8.1 > > > Hi Folks , > Thanks for your good work done in Collection Framework . > It would be good if you add functionality to sort the collection based on bean's property name . ( CollectionsUtils,java) > For example i have List , i should be able to sort (ascending or desending ) based on person's salary (or) firstName (or) lastName (or) may be the combination of above > below is the equivalent in SQL > (select * from person order by salary,firtsName,lastName asc ) > method looks like > public static void sort(List list, boolean isAscending,String... beanPropertyName) { > Collection> beanComparatorCollection = new ArrayList>(beanPropertyName.length); > for(int i =0;i { > beanComparatorCollection.add(new BeanComparator(beanPropertyName[i])); > } > Comparator finalComparator = ComparatorUtils.chainedComparator(beanComparatorCollection); > if (!isAscending) { > finalComparator = new ReverseComparator(finalComparator); > } > Collections.sort(list, finalComparator); > } > Please let me know if you need any details , infact i able to submit patch too . -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.