Use smart_less when sorting collections

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@967 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-03 19:26:23 +00:00
parent 92947dc5b8
commit aa950d1821
+5 -1
View File
@@ -201,6 +201,10 @@ int position_in_vector(const ScriptValueP& of, const ScriptValueP& in, const Scr
return -1; // TODO?
}
inline bool smart_less_first(const pair<String,ScriptValueP>& a, const pair<String,ScriptValueP>& b) {
return smart_less(a.first, b.first);
}
// sort a script list
ScriptValueP sort_script(Context& ctx, const ScriptValueP& list, ScriptValue& order_by) {
ScriptType list_t = list->type();
@@ -219,7 +223,7 @@ ScriptValueP sort_script(Context& ctx, const ScriptValueP& list, ScriptValue& or
ctx.setVariable(set ? _("card") : _("input"), v);
values.push_back(make_pair(order_by.eval(ctx)->toString(), v));
}
sort(values.begin(), values.end());
sort(values.begin(), values.end(), smart_less_first);
// return collection
intrusive_ptr<ScriptCustomCollection> ret(new ScriptCustomCollection());
FOR_EACH(v, values) {