Index: /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp	(revision 60644)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp	(revision 60645)
@@ -104,19 +104,28 @@
             m_pFormatButtonGroup = new QButtonGroup(this);
             {
-                CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
-                const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
-                for (int i = 0; i < medFormats.size(); ++i)
+                /* Enumerate medium formats in special order: */
+                CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
+                const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
+                QMap<QString, CMediumFormat> vdi, preferred;
+                foreach (const CMediumFormat &format, formats)
                 {
-                    const CMediumFormat &medFormat = medFormats[i];
-                    if (medFormat.GetName() == "VDI")
-                        addFormatButton(this, pFormatLayout, medFormat);
+                    /* VDI goes first: */
+                    if (format.GetName() == "VDI")
+                        vdi[format.GetId()] = format;
+                    else
+                    {
+                        const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
+                        /* Then preferred: */
+                        if (capabilities.contains(KMediumFormatCapabilities_Preferred))
+                            preferred[format.GetId()] = format;
+                    }
                 }
-                for (int i = 0; i < medFormats.size(); ++i)
-                {
-                    const CMediumFormat &medFormat = medFormats[i];
-                    const QVector<KMediumFormatCapabilities> &capabilities = medFormat.GetCapabilities();
-                    if (medFormat.GetName() != "VDI" && capabilities.contains(KMediumFormatCapabilities_Preferred))
-                        addFormatButton(this, pFormatLayout, medFormat);
-                }
+
+                /* Create buttons for VDI and preferred: */
+                foreach (const QString &strId, vdi.keys())
+                    addFormatButton(this, pFormatLayout, vdi.value(strId));
+                foreach (const QString &strId, preferred.keys())
+                    addFormatButton(this, pFormatLayout, preferred.value(strId));
+
                 if (!m_pFormatButtonGroup->buttons().isEmpty())
                 {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp	(revision 60644)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp	(revision 60645)
@@ -94,19 +94,33 @@
                 m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt);
                 {
-                    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
-                    const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
-                    for (int i = 0; i < medFormats.size(); ++i)
+                    /* Enumerate medium formats in special order: */
+                    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
+                    const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
+                    QMap<QString, CMediumFormat> vdi, preferred, others;
+                    foreach (const CMediumFormat &format, formats)
                     {
-                        const CMediumFormat &medFormat = medFormats[i];
-                        if (medFormat.GetName() == "VDI")
-                            addFormatButton(m_pFormatCnt, pFormatCntLayout, medFormat, true);
+                        /* VDI goes first: */
+                        if (format.GetName() == "VDI")
+                            vdi[format.GetId()] = format;
+                        else
+                        {
+                            const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
+                            /* Then goes preferred: */
+                            if (capabilities.contains(KMediumFormatCapabilities_Preferred))
+                                preferred[format.GetId()] = format;
+                            /* Then others: */
+                            else
+                                others[format.GetId()] = format;
+                        }
                     }
-                    for (int i = 0; i < medFormats.size(); ++i)
-                    {
-                        const CMediumFormat &medFormat = medFormats[i];
-                        const QVector<KMediumFormatCapabilities> &capabilities = medFormat.GetCapabilities();
-                        if (medFormat.GetName() != "VDI")
-                            addFormatButton(m_pFormatCnt, pFormatCntLayout, medFormat, capabilities.contains(KMediumFormatCapabilities_Preferred));
-                    }
+
+                    /* Create buttons for VDI, preferred and others: */
+                    foreach (const QString &strId, vdi.keys())
+                        addFormatButton(this, pFormatCntLayout, vdi.value(strId), true);
+                    foreach (const QString &strId, preferred.keys())
+                        addFormatButton(this, pFormatCntLayout, preferred.value(strId), true);
+                    foreach (const QString &strId, others.keys())
+                        addFormatButton(this, pFormatCntLayout, others.value(strId));
+
                     if (!m_pFormatButtonGroup->buttons().isEmpty())
                     {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp	(revision 60644)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp	(revision 60645)
@@ -104,19 +104,28 @@
             m_pFormatButtonGroup = new QButtonGroup(this);
             {
-                CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
-                const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
-                for (int i = 0; i < medFormats.size(); ++i)
+                /* Enumerate medium formats in special order: */
+                CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
+                const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
+                QMap<QString, CMediumFormat> vdi, preferred;
+                foreach (const CMediumFormat &format, formats)
                 {
-                    const CMediumFormat &medFormat = medFormats[i];
-                    if (medFormat.GetName() == "VDI")
-                        addFormatButton(this, pFormatLayout, medFormat);
+                    /* VDI goes first: */
+                    if (format.GetName() == "VDI")
+                        vdi[format.GetId()] = format;
+                    else
+                    {
+                        const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
+                        /* Then preferred: */
+                        if (capabilities.contains(KMediumFormatCapabilities_Preferred))
+                            preferred[format.GetId()] = format;
+                    }
                 }
-                for (int i = 0; i < medFormats.size(); ++i)
-                {
-                    const CMediumFormat &medFormat = medFormats[i];
-                    const QVector<KMediumFormatCapabilities> &capabilities = medFormat.GetCapabilities();
-                    if (medFormat.GetName() != "VDI" && capabilities.contains(KMediumFormatCapabilities_Preferred))
-                        addFormatButton(this, pFormatLayout, medFormat);
-                }
+
+                /* Create buttons for VDI and preferred: */
+                foreach (const QString &strId, vdi.keys())
+                    addFormatButton(this, pFormatLayout, vdi.value(strId));
+                foreach (const QString &strId, preferred.keys())
+                    addFormatButton(this, pFormatLayout, preferred.value(strId));
+
                 if (!m_pFormatButtonGroup->buttons().isEmpty())
                 {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp	(revision 60644)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp	(revision 60645)
@@ -122,19 +122,33 @@
                 m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt);
                 {
-                    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
-                    const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
-                    for (int i = 0; i < medFormats.size(); ++i)
+                    /* Enumerate medium formats in special order: */
+                    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
+                    const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
+                    QMap<QString, CMediumFormat> vdi, preferred, others;
+                    foreach (const CMediumFormat &format, formats)
                     {
-                        const CMediumFormat &medFormat = medFormats[i];
-                        if (medFormat.GetName() == "VDI")
-                            addFormatButton(m_pFormatCnt, pFormatCntLayout, medFormat, true);
+                        /* VDI goes first: */
+                        if (format.GetName() == "VDI")
+                            vdi[format.GetId()] = format;
+                        else
+                        {
+                            const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
+                            /* Then goes preferred: */
+                            if (capabilities.contains(KMediumFormatCapabilities_Preferred))
+                                preferred[format.GetId()] = format;
+                            /* Then others: */
+                            else
+                                others[format.GetId()] = format;
+                        }
                     }
-                    for (int i = 0; i < medFormats.size(); ++i)
-                    {
-                        const CMediumFormat &medFormat = medFormats[i];
-                        const QVector<KMediumFormatCapabilities> &capabilities = medFormat.GetCapabilities();
-                        if (medFormat.GetName() != "VDI")
-                            addFormatButton(m_pFormatCnt, pFormatCntLayout, medFormat, capabilities.contains(KMediumFormatCapabilities_Preferred));
-                    }
+
+                    /* Create buttons for VDI, preferred and others: */
+                    foreach (const QString &strId, vdi.keys())
+                        addFormatButton(this, pFormatCntLayout, vdi.value(strId), true);
+                    foreach (const QString &strId, preferred.keys())
+                        addFormatButton(this, pFormatCntLayout, preferred.value(strId), true);
+                    foreach (const QString &strId, others.keys())
+                        addFormatButton(this, pFormatCntLayout, others.value(strId));
+
                     if (!m_pFormatButtonGroup->buttons().isEmpty())
                     {
