Fix a bug in qsort

Try `qsort [3,3]`. Under the old code, you'd get `[3,3,3]` out.
Fixed bug regarding insertion in SortedMap.
Fixes idris-lang/Idris-dev#1394. Solution based on the diagnosis in @sebzim4500s comment.
Merge pull request #1408 from ahmadsalim/bug/sortedmap

Fixed bug regarding insertion in SortedMap.
Merge pull request #1406 from jthemphill/fix-qsort

Fix a bug in qsort
Add for and for_
Merge pull request #1409 from Melvar/for

Add for and for_