Alphabetically files sort seems to bug. I've made a modification to brilliant_gallery.module file.

line 318 : replace sort( $retval_dimensions ); width usort( $retval_dimensions, "compareFileElt" );
I've add a function : function compareFileElt($a, $b) {return strcmp($a['file'], $b['file']);}

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

krynsky’s picture

I just upgraded to 3.1 and this bug still exists. Luckily, using the same code changes above I was able to fix the issue in 3.1 as well.

meichr’s picture

Title: Alphabetically files sort bug » Alphabetically files sort bug - all versions (up to 5.x-4.x-dev, up to 6.x-4.x-dev) affected
Version: 5.x-3.0 » 6.x-4.x-dev
FileSize
346 bytes
353 bytes

Some days ago a customer told me, he would have a big problem with using brilliant gallery filter tags in his blog entries. He has one unpublished brilliant gallery directory from which he uses individual images to be put directly into the text of his blogs. But though he added later images with higher numbers preceding the file name, suddenly images changed in older blog posts. When I investigated in the source code of BG I found out that the problem is caused by a problem with the sort order. Later I found this active bug report in the issues.

Result of investigation:

This original bug report was posted for the version 5.x-3.0 of Brilliant Gallery, but the error is still in the code of all versions including the dev versions of Dec 24th, 2009.

The bug is caused by trying to sort a multidimensional array by using the php array sorting function "sort", which is only capable of sorting single dimension arrays. The bug affects your gallery by not correctly sorting the images of a gallery in alphabetical order of the file name. E.g. if you use a filter tag to display only some of the images of a gallery within a text, you might end up getting the wrong images displayed, because you thought to count the first image by alphabetical filename order and brilliant gallery's code sorted it in another wrong way.

The correction previously posted by my predecessor posters could be used, though I implemented another version using php's function array_multisort which correctly sorts the multidimensional array.

The two attached patches were created for the current dev versions 5.x-4.x-dev and 6.x-4.x-dev, but might work for a range of versions including the current stable versions.

If those patches or a similar solution for the sort order problem to the current dev versions could be committed this longtime problem could be finally solved.