It automatically sorts by a jQuery function, so you can create your own and have it sort by that. For instance, I created a getCompany jQuery method below that extracts the company out of "Name (Company)". You could then do $("select").sortSelectBy("getCompany").
jQuery.fn.sortSelectBy = function(sort) {
return this.each (function(i, self) {
sorted = jQuery("option", this).get().sort(function(a,b) { return (jQuery(a)[sort]() > jQuery(b)[sort]()) ? 1 : -1 })
jQuery(this).empty().append(sorted)
})
}
jQuery.fn.getCompany = function() {
company = this.html().match(/\(([^\)]*)\)/)
if(company) return company[1];
}
--
Yehuda Katz
Web Developer | Wycats Designs
(ph) 718.877.1325
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
