Simplify sorting logic to a single std::sort call

This commit is contained in:
MrMelon 2022-06-06 22:18:19 +01:00
parent 1c60e9b4fc
commit 89d4405563
No known key found for this signature in database
GPG Key ID: B0ADD5395BCDAAB6

View File

@ -59,26 +59,9 @@ IconList::IconList(const QStringList &builtinPaths, QString path, QObject *paren
void IconList::sortIconList() void IconList::sortIconList()
{ {
qDebug() << "Sorting icon list..."; qDebug() << "Sorting icon list...";
std::sort(icons.begin(), icons.end(), [](const MMCIcon& a, const MMCIcon& b) {
QVector<MMCIcon> newIcons = QVector<MMCIcon>(); return a.m_key.compare(b.m_key) < 0;
QVectorIterator<MMCIcon> iconIter(icons); });
iconLoop:
while(iconIter.hasNext())
{
MMCIcon a = iconIter.next();
for(int i=0;i<newIcons.size();i++)
{
if(a.m_key.compare(newIcons[i].m_key) < 0)
{
newIcons.insert(i,a);
goto iconLoop;
}
}
newIcons.append(a);
}
icons = newIcons;
reindex(); reindex();
} }