More suitable sorting algorithm applied
This commit is contained in:
parent
e36516c1c7
commit
d4d28f760b
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user