chainging sorting to generic solutions