Return the composition index for a given composition.
The index is assigned by lexicographically decreasing order.