Initial sorting implementation