BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-19-2011, 05:17 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2009
Model: 8300
PIN: N/A
Carrier: developer
Posts: 37
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Blackberry API to sort the list in alphabetical order

Please Login to Remove!

HI,
I am developing Blackberry application using JDE 4.2. I want to sort the list in alphabetical order as like blackberry contact, with A, B , C..... as header.
Is there any API available for this?

Please help me out on this.
Thanks in advance.
Offline  
Old 04-19-2011, 05:50 AM   #2 (permalink)
New Member
 
Join Date: Apr 2011
Model: 8900
PIN: N/A
Carrier: Airtel
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Blackberry API to sort the list in alphabetical order

If you are using a vector for storing the list elements then
you can use Java Comparator interface to sort elements of a vector
If you have Employee objects in your vector, then you can sort the vector as follows:

class Name implements Comparator{

public int compare(Object o1, Object o2) {

int result = ((Employee) o1).getEmpName().compareTo(((Employee) o2).getEmpName());

if(result == 0){

int val11 = ((Employee) o1).getEmpId();
int val22= ((Employee) o1).getEmpId();
return val11 < val22 ? -1 : val11 == val22 ? 0 : 1;
}else{
return result;
}

}

empVector.setSortComparator(new Name());
empVector.setSort(true);
Offline  
Old 05-08-2011, 11:37 AM   #3 (permalink)
New Member
 
Join Date: May 2011
Model: 7100T
PIN: N/A
Carrier: wtf
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Blackberry API to sort the list in alphabetical order

You could parse the List to a Collection and call Collection.sort();
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Blackberry API to sort the list in alphabetical order
Thread Thread Starter Forum Replies Last Post
Bes 4.1.7 Mr2 Mikey_AGBoston BES Admin Corner 5 04-29-2010 02:37 PM
Web Desktop 5 no application loader Walter_Str BES Admin Corner 2 08-27-2009 07:05 AM
New to BES admin , need help with messages. bigwig BES Admin Corner 5 10-17-2007 10:59 AM
T-Mobile's Smart Phone Comparison Chart! UPDATED & NEW! :) secrecyguy General BlackBerry Discussion 5 06-02-2007 02:42 PM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.