adding counting sort + some refactoring of sorts