Ordered devices
Fix an issue in the ordering of terms