Here is a link to a Scriptcard bubble sorting algorithm. That example is hardcoded to sorting ascending, but you can change the -gt line that calls the BubbleUp function to read -lt instead to sort descending, e.g. --?[$Roll[$i.Total]] -gt [$Roll[$j.Total]] |>BubbleUp;[$i.Total];[$j.Total] should be changed to: --?[$Roll[$i.Total]] -lt [$Roll[$j.Total]] |>BubbleUp;[$i.Total];[$j.Total] If you have a variable number of rolls it gets a little more complicated. I thought I had a version that did this but can't seem to put my hands on it. Another approach could be assigning the rolls to an array, performing an array;sort function on it, and reassigning to roll variables in a loop. The scriptcards wiki has more info on this in the " Built-in Functions " section.