Added mountain/branch/lake sorting

Takes almost 6 seconds on most of the S3 test cases when only 2 seconds
are allowed, which is definitely not good. Room for optimization.