PDA

View Full Version : PHP Photo Album script v2.11 - localeCompare()



jscheuer1
12-03-2009, 06:52 PM
1) Script Title: PHP Photo Album script v2.11

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

3) Describe problem: The sorting algorithm for file doesn't work in Opera. This one does:


if (setting.sortby[0]=="file") //sort by filename (asc)
this.albumvar.images.sort(function(a, b){var x = a[1].toLowerCase(), y = b[1].toLowerCase(); return x > y? 1 : x < y? -1 : a[1] > b[1]? 1 : -1;});

and also works in other browsers, presumably all as it is written to return the expected values.

The main drawback of the current localeCompare() method is that it is non-standard. So support varies in browsers. However, it also will vary (even when fully supported by a given browser) by the locale setting as to language on the individual computer viewing the page.