0

I am trying to sort a Table with dynamic data by selecting a radio button.

I can access the data in my table this array:

    var arr = [];

        for (var i = 0; i < tbl.children.length; i++)
        {
            var j = i +1;

            var cell1 = document.getElementById("tbl_"+container_element.id).childNodes[i].cells[0].textContent;
            var cell2 = document.getElementById("tbl_"+container_element.id).childNodes[i].cells[1].textContent;
            var cell3 = document.getElementById("tbl_"+container_element.id).childNodes[i].cells[2].textContent;    

            //arr[i] = [{"cn":cell1, "pr":cell2, "ch":cell3}];

            arr[cell1] = {
                cn: cell1,
                pr: cell2,
                ch: cell3
            };
        }

        console.log(arr['Name of Object']);

So I can access on particular row by setting a name from the array so I can access the properties in that object.

How do I sort my table by referring to one of those propeties? That way if I have multiple radio buttons, I can sort by different properties.

jwknz
  • 6,598
  • 16
  • 72
  • 115
  • I have seen the question of which this is marked as a duplicate, but I can't seem to get that to work since I have a different array structure?? – jwknz Apr 16 '15 at 21:52
  • This answer worked for me from the duplicate quesiton http://stackoverflow.com/a/11412761/892628 – jwknz Apr 16 '15 at 22:32

0 Answers0