From a248302132999bc27fbeb0835a2aa1771f04096d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 29 Apr 2020 18:12:33 +0200 Subject: [PATCH] [poincare] Unit: define order on representatives in a way that time addition are displayed: years + months + ... + seconds --- poincare/src/unit.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/poincare/src/unit.cpp b/poincare/src/unit.cpp index 74642d7d4..2aa75e81b 100644 --- a/poincare/src/unit.cpp +++ b/poincare/src/unit.cpp @@ -183,7 +183,10 @@ int UnitNode::simplificationOrderSameType(const ExpressionNode * e, bool ascendi } const ptrdiff_t repdiff = eNode->representative() - m_representative; if (repdiff != 0) { - return repdiff; + /* We order representatives in the reverse order as how they're stored in + * the representatives table. This enables to sort addition of time as: + * year + month + days + hours + minutes + seconds. */ + return -repdiff; } const ptrdiff_t prediff = eNode->prefix() - m_prefix; return prediff;