using std::sort intead of qSort