Coding for the framework to sort the order of n-gram variable candidates