def _sort_orders(orders):
    """Sort a list of possible orders that are to be tried so that the simplest
    ones are at the beginning.
    """
    def weight(p, d, q, P, D, Q):
        """Assigns a weight to a given model order which accroding to which
        orders are sorted. It is only a simple heuristic that makes it so that
        the simplest models are sorted first.
        """
        cost = 0
        if P + D + Q:
            cost += 1000

        cost += p**2 + d**2 + q**2
        cost += P**3 + 2*d**3 + 3*q**3

        return cost

    orders = [(weight(*o), o) for o in orders]
    orders.sort()
    orders = [x[1] for x in orders]

    return orders