Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C++ (https://www.askmehelpdesk.com/forumdisplay.php?f=439)
-   -   What is the best way to sort an array of doubles in ascending order using c++? (https://www.askmehelpdesk.com/showthread.php?t=658618)

  • May 9, 2012, 03:01 AM
    buckboard
    What is the best way to sort an array of doubles in ascending order using c++?
    Hi,
    Ive got an array filled with about 2000 different doubles. These are read in from an external .txt. I now want to calculate the median of these numbers. For this I have to sort the array in ascending order. My first attempt was std::sort


    for (I=1; I<2002; I++)
    {
    datenSatz>>zahl;
    daten[i]=zahl;
    std::sort(daten, daten+2002);
    cout<<daten[i]<<endl;
    berechnungen<<daten[i]<<endl;

    }

    and then printing it in a .txt. This works fine, just that the result is pure bogus. It sorts numbers allright, just not mine. Not too sure what it actually does with it.

    Any help?

  • All times are GMT -7. The time now is 02:59 AM.