Added support for nested sorting for script sorting and geo sorting.
Closes #3044