Keywords: table sorting algorithm
Foreword: Many friends will have a wish to click on the table title to reach the need to order the table, and have many pre-sales forms, but their code is often complicated and is not suitable for newbie learning. Even the newbie who can't understand the code :), so I have to write a form sorting solution yourself.
Implementation Method: Table Moveow (I, J) Method This method meaning is to move the first row to JU, and other rows are in turn up or down.
Implementation Algorithm: The principle of bubbling method is to compare the first number and the number of times the number behind, (in case from large to small sort as an example, if there is N number to sort) If you find a larger than this Then, in exchange with this number, this will perform N-1 comparison. After the first round is compared, the top of the first one must be the maximum number. The second number is sequentially compared. At this time, it is necessary to perform N-2 comparisons, and the class is pushed into a total of N-1 N-2 3 2 1 = n * n / 2 comparison.
Compare content: row [i] .cells [j] .innertext or above method can get the table content, which is required for comparison.
Ok, there is a premise, we must let the form sorted very simple, we use the bubbling method to sort the form, using the above principle is to use the contents of each line of the table and perform Moverow for sorting.