diff --git a/poincare/include/poincare/expression.h b/poincare/include/poincare/expression.h index a89180c21..912bdf1a4 100644 --- a/poincare/include/poincare/expression.h +++ b/poincare/include/poincare/expression.h @@ -116,6 +116,10 @@ public: /* Sorting */ virtual bool isCommutative() const { return false; } virtual void sort(); + /* compareTo returns: + * 1 if this > e + * -1 if this < e + * 0 if this == e */ virtual int compareTo(const Expression * e) const; /* Layout Engine */ diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 2acda2905..d18ab884d 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -97,12 +97,12 @@ void Expression::sort() { } int Expression::compareTo(const Expression * e) const { - if (e->type() > this->type()) { - return 1; - } - if (e->type() < this->type()) { + if (this->type() < e->type()) { return -1; } + if (this->type() > e->type()) { + return 1; + } for (int i = 0; i < this->numberOfOperands(); i++) { // The NULL node is the least node type. if (e->numberOfOperands() <= i) {