Only resort a tree's contents when required.
Since most trees contain files and no subtrees most trees will
always be sorted 'correctly' for both our in memory format and the
external GIT format. Since attempting to resort an already sorted
list will not run very quickly when compared to not resorting the
list at all we try to detect if a Tree is present in the current
tree's contents and only resort if one (or more) is found. If no
Trees are present then no sorting is necessary.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>