hacking on Countingsort like things, not sure I am getting it right