11 static ex_is_less less;
12 if(
a.is_equal(b))
return false;
15 if(is_a<numeric>(
a) && is_a<numeric>(b)) {
17 auto abr = real_part(ab);
18 if(!is_zero(abr))
return abr<0;
19 else return imag_part(ab)<0;
21 if(is_a<numeric>(
a))
return true;
22 if(is_a<numeric>(b))
return false;
25 if(is_a<symbol>(
a) && is_a<symbol>(b)) {
26 string sa = ex_to<symbol>(
a).get_name();
27 string sb = ex_to<symbol>(b).get_name();
30 if(is_a<symbol>(
a))
return true;
31 if(is_a<symbol>(b))
return false;
34 if(is_a<lst>(
a) && is_a<lst>(b)) {
37 if(na!=nb)
return (na<nb);
38 for(
int i=0; i<na; i++) {
39 if(
a.op(i).is_equal(b.op(i)))
continue;
44 if(is_a<lst>(b))
return true;
45 if(is_a<lst>(
a))
return false;
55 std::sort(ivec.begin(), ivec.end(), [less](
const auto &
a,
const auto &b){
56 if(less) return ex_less(a,b);
57 else return ex_less(b,a);
68 std::sort(ivec.begin(), ivec.end(), [ki,less](
const auto &
as,
const auto &bs){
69 if(less) return ex_less(as.op(ki),bs.op(ki));
70 else return ex_less(bs.op(ki),as.op(ki));
82 for(
auto i=0; i<ivec.size(); i++) ilst.let_op(i) = ivec[i];
94 for(
auto i=0; i<ivec.size(); i++) ilst.let_op(i) = ivec[i];
bool ex_less(const ex &a, const ex &b)
exvector lst2vec(const lst &alst)
convert lst to exvector
void sort_lst_by(lst &ilst, int n, bool less=true)
sort the list in less order, or the reverse
void sort_vec(exvector &ivec, bool less=true)
sort the list in less order, or the reverse
void sort_lst(lst &ilst, bool less=true)
sort the list in less order, or the reverse
void sort_vec_by(exvector &ivec, int n, bool less=true)
sort the list in less order, or the reverse