Sort with assumptions

How about:

list[[Ordering[list /. _Subscript -> 1]]]

{-Subscript[x, 3] - Subscript[x, 9], -Subscript[x, 9], 0, Subscript[x, 7]}

So basically we sort it the way it would be sorted with all subscripts == 1.


Here is a possibility:

sortWithAssumptions[list_, assum_] := Module[{order},
    order[a_, b_] := Simplify[a < b, assum];
    Sort[list, order]
]

For your example:

sortWithAssumptions[
    {0,Subscript[x,7],-Subscript[x,3]-Subscript[x,9],-Subscript[x,9]},
    Subscript[x,3]>0&&Subscript[x,7]>0&&Subscript[x,9]>0
] //TeXForm

$\left\{-x_3-x_9,-x_9,0,x_7\right\}$

Another example:

sortWithAssumptions[
    {0,Subscript[x,7],-Subscript[x,3]-Subscript[x,9],-Subscript[x,9], Subscript[x,9]},
    Subscript[x,3]>0&&Subscript[x,7]>0&&Subscript[x,9]>0&&Subscript[x,7]<Subscript[x,9]
] //TeXForm

$\left\{-x_3-x_9,-x_9,0,x_7,x_9\right\}$


Sort[list, TrueQ@Simplify[#1 < #2, _Subscript > 0] &]

(* Out: {-Subscript[x, 3] - Subscript[x, 9], -Subscript[x, 9], 0, Subscript[x, 7]} *)