use keydir

I extracted the sorted array & ltgt-stuff (ranges) to a module of it's own (so I could reuse it for github.com/kesla/medeadown) - let's use that for memdown.