Fix for #1578 - Depends on stableSort, so added to PR#2500.

Object.each is not necessarily alphabetic when iterating an object's properties, so we pull the folders out of the object, add them to an array, and sort that.