1. #1

    Question about sort in Lua ( weakaura )

    Hello,

    I'm trying to sort a table for a weakaura but I do not see how to do it ( sort by the attribut value).

    Example :

    player = {
    value = 34
    class = Warrior,
    id = 1
    },
    {
    value = 1,
    class = mage,
    id = 2
    },
    {
    value = 3443,
    class = Paladin,,
    class = 3
    }

    I want :

    player = {
    value = 1,
    class = mage,
    id = 2
    },
    {
    value = 34
    class = Warrior,
    id = 1
    },
    {
    value = 3443,
    class = Paladin,
    class = 3
    }


    Someone an idea how to do this ?

  2. #2
    table.sort(myTable, function(x,y)
    return x.value <y.value
    end)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •