aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes Sort text in select Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Sort text in select" Watch "Sort text in select" New topic
Author

Sort text in select

Sophie Cameron
Greenhorn

Joined: Jun 05, 2005
Posts: 24
We wrote code to sort select text but it is not efficient if there are more than 1,000 entries. Since select.options is read-only, we can't use Array.sort() to do it.

If you need to sort select entries, how would you do it?

Thanks,
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
What are you trying to do with this, there might be a better way of doing it.

Where is the information coming from?

Eric
Sophie Cameron
Greenhorn

Joined: Jun 05, 2005
Posts: 24
Hi Eric,

What I want to do is when a new entry needs to be added to a select, I want it to be added alphabetically. The original select is already rendered alphabetically.

Here is my code to do it:
Many Option objects are created in the second loop, which is the bottleneck. The performance could be [bold]greatly[/bold] improved if the could be replaced with but actually not.

Thanks,
Sophie Cameron
Greenhorn

Joined: Jun 05, 2005
Posts: 24
The leftSelect in the second for loop should be mySelect.

Sorry about that.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Sort text in select
 
Similar Threads
sort Strings on app or database side?
JDBC Query Help!!!!!
Need technical guidance to solve my issue
some difficult questions!
Sorting hashtable in j2me