Changed toArray to return a sorted array.
Added expandRange and compressRange methods.