L = shellingOrder S
If $S$ is pure, then definition III.2.1 in [St] is used. That is, $S$ is shellable if its facets can be ordered $F_1, .., F_n$ so that the difference in the $j$th and $j1$th subcomplex has a unique minimal face, for $2 \leq j \leq n$.
If $S$ is nonpure, then definition 2.1 in [BW1] is used. That is, a simplicial complex $S$ is shellable if the facets of $S$ can be ordered $F_1, .., F_n$ such that the intersection of the faces of the first $j1$ with the faces of the $F_j$ is pure and $dim F_j  1$dimensional.
This function attempts to build up a shelling order of $S$ recursively. In particular, a depthfirst search is used to attempt to build up a shelling order from the bottom, that is, from the first facet in the order.
In the case when $S$ is nonpure, then the search is restricted to the maximal dimension facets remaining to be added. This allows a shelling order in reverse dimension order to be returned whenever $S$ is indeed shellable.






The options Random and Permutation can be used to try to find alternate shelling orders. Random applies a random permutation to the facet list and Permutation applies a supplied permutation to the list. In the nonpure case, the facets are subsequently ordered in reverse dimension order but retaining the ordering within dimensions.
The options Random and Permutation are mutually exclusive.




The shelling order is cached if it exists, however, if either option is used, then the cache is ignored.
The object shellingOrder is a method function with options.