how can i find the highest number in the array and sort the array so it has the highest numbers first?
I am using jQuery also, if that should make it easier. I cannot figure out how to sort it, and then outputs the sorted arrays with html into usersInRoom div.
Hope someone can help me though this!
I have readed a little bit about the "max" in javascript, but it was complicate, and didn't match my code.
I will sort the mydivs[.......]['number'] and not mydivs, because it contains an array in an array.
<div id="usersInRoom">
    <div class="entry in_room" id="userInRoom-2" style="background-color: rgb(255, 255, 255);">
        <table style="width:100%">
            <tbody>
            <tr>
                <td style="width:32px">
                    <img
                        src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn1/c33.33.414.414/s200x200/996882_221295918024677_1913237122_n.jpg"
                        style="height:32px;width:32px">
                </td>
                <td style="vertical-align:middle"><strong>Stefanie Pedersen</strong>
                </td>
                <td align="right" style="vertical-align:middle;color:#999"><span id="exp-2" class="exp">6</span> exp.
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="entry in_room" id="userInRoom-1" style="background-color: rgb(155, 229, 162);">
        <table style="width:100%">
            <tbody>
            <tr>
                <td style="width:32px">
                    <img
                        src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc1/c176.49.608.608/s200x200/429356_10151257167066983_1091687280_n.jpg"
                        style="height:32px;width:32px">
                </td>
                <td style="vertical-align:middle"><strong>Bare Kald Mig Jesper</strong>
                </td>
                <td align="right" style="vertical-align:middle;color:#999"><span id="exp-1" class="exp">14</span> exp.
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
And here is my jQuery code to insert the HTML and the numbers into array, after this it should "just" sort it and outputs it again.
<script>
var numbers = [];
var mydivs = [];
var arr = $("#usersInRoom").find(".exp");
$.each(arr, function (e) {
    var eq = arr[e];
    console.log(eq);
    mydivs.push({
        "html": $(eq).parents(".entry").parents("div").html(),
        "number": parseInt($(eq).text())
    });
});
</script>
I WILL SORT THE mydivs[.......]['number'] <----