Fixed bug when entities were compared in reverse order.