Sort galleries by name
This commit is contained in:
parent
f59281a2fe
commit
d38b420238
@ -157,6 +157,13 @@ void va_rm_gallery( void* gallery ) {
|
||||
destroy_gallery_info( (struct gallery_info*)gallery, 0 );
|
||||
}
|
||||
|
||||
/* Helper Function: Compare two galleries ... used below */
|
||||
int gallerycmp( const void* a_ptr, const void* b_ptr ) {
|
||||
struct gallery_info* a = (struct gallery_info*)a_ptr;
|
||||
struct gallery_info* b = (struct gallery_info*)b_ptr;
|
||||
return strcasecmp( a->gallery_name, b->gallery_name );
|
||||
}
|
||||
|
||||
/* The following function returns a linked-list of galleries known to the
|
||||
* webapp, or NULL if such a list can't be constructed (due to memory
|
||||
* constraints).
|
||||
@ -237,5 +244,11 @@ struct gallery_list* list_galleries() {
|
||||
* variable array and return the static one.
|
||||
*/
|
||||
destroy_vararray( va );
|
||||
|
||||
/* Sort the list before returning */
|
||||
if ( list != NULL )
|
||||
if ( list->length > 1 )
|
||||
sort_array( (void**)list->gallery, list->length,
|
||||
&gallerycmp );
|
||||
return list;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user