More suitable sorting algorithm applied

This commit is contained in:
Alexander S. Aganichev 2001-12-14 15:48:19 +00:00
parent e36516c1c7
commit d4d28f760b

View File

@ -24,6 +24,7 @@
// Arealist functions. // Arealist functions.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#include <algorithm>
#include <golded.h> #include <golded.h>
@ -205,6 +206,11 @@ extern "C" int AreaListCmp(const Area** __a, const Area** __b) {
return cmp; return cmp;
} }
static bool AreaListCmp2(const Area* a, const Area* b) {
return AreaListCmp(&a, &b) < 0;
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// Arealist sort areas // Arealist sort areas
@ -216,8 +222,9 @@ void AreaList::Sort(const char* specs, int first, int last) {
strcpy(sortspec, CFG->arealistsort); strcpy(sortspec, CFG->arealistsort);
if(last == -1) if(last == -1)
last = idx.size(); last = idx.size();
if(*sortspec) if(*sortspec) {
qsort(&idx[first], last-first, sizeof(Area *), (StdCmpCP)AreaListCmp); sort(idx.begin()+first, idx.begin()+last, AreaListCmp2);
}
} }