diff --git a/libdmapsharing/dacp-share.c b/libdmapsharing/dacp-share.c
index 16579e9..0c27b5b 100644
--- a/libdmapsharing/dacp-share.c
+++ b/libdmapsharing/dacp-share.c
@@ -882,7 +882,7 @@ dacp_share_ctrl_int (DMAPShare *share,
 			sorted_records = g_hash_table_get_values (records);
 			sort_by = g_hash_table_lookup (query, "sort");
 			if (g_strcmp0 (sort_by, "album") == 0) {
-				sorted_records = g_list_sort (sorted_records, (GCompareFunc) daap_record_cmp_by_album);
+				sorted_records = g_list_sort_with_data (sorted_records, (GCompareFunc) daap_record_cmp_by_album, db);
 			} else if (sort_by != NULL) {
 				g_warning ("Unknown sort column: %s", sort_by);
 			}
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 49f5c7b..1c714df 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -1714,7 +1714,7 @@ _dmap_share_databases (DMAPShare *share,
 			sort_by = g_hash_table_lookup (query, "sort");
 			keys = g_hash_table_get_keys (records);
 			if (g_strcmp0 (sort_by, "album") == 0) {
-				keys = g_list_sort_with_data (keys, (GCompareDataFunc) daap_record_cmp_by_album, records);
+				keys = g_list_sort_with_data (keys, (GCompareDataFunc) daap_record_cmp_by_album, share->priv->db);
 			} else if (sort_by != NULL) {
 				g_warning ("Unknown sort column: %s", sort_by);
 			}
