diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index e33856ed0a..cdba3c20f0 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -3933,12 +3933,12 @@ xaccAccountFindOpenLots (const Account *acc, continue; /* Ok, this is a valid lot. Add it to our list of lots */ - if (sort_func) - retval = g_list_insert_sorted (retval, lot, sort_func); - else - retval = g_list_prepend (retval, lot); + retval = g_list_prepend (retval, lot); } + if (sort_func) + retval = g_list_sort (retval, sort_func); + return retval; } diff --git a/libgnucash/engine/gncOwner.c b/libgnucash/engine/gncOwner.c index 03e938fd94..456fefdf8f 100644 --- a/libgnucash/engine/gncOwner.c +++ b/libgnucash/engine/gncOwner.c @@ -1045,13 +1045,15 @@ gncOwnerSetLotLinkMemo (Transaction *ll_txn) title = g_strdup_printf ("%s %s", gncInvoiceGetTypeString (invoice), gncInvoiceGetID (invoice)); - titles = g_list_insert_sorted (titles, title, (GCompareFunc)g_strcmp0); + titles = g_list_prepend (titles, title); splits = g_list_prepend (splits, split); // splits don't need to be sorted } if (!titles) return; // We didn't find document lots + titles = g_list_sort (titles, (GCompareFunc)g_strcmp0); + // Create the memo as we'd want it to be new_memo = g_strconcat (memo_prefix, titles->data, NULL); for (titer = titles->next; titer; titer = titer->next)