If I want to sort either by code, or by description, or by company, then sorting goes by all fields. If I want to sort either by price, or by delivery date, or by cash. - then sorting goes inside the merged block. I store the data in json (product ID, number of descendants, ID descendant, company, code, description, cash, delivery time, price). In the plan, send json to ajax server with a request and return the finished html table sorted. Question how to sort on the server? What should I use? Example table: http://prntscr.com/980y42 I have bitrix data, the template components are used, that is, there is no connection to the database, that is, the template itself does everything. Bitriksovskaya sorting does not suit me due to the fact that each customer shows one data, another other data, that is, is solved individually for each client.
Here is the code for the catalog_section component
<table class="definition-table"> <thead> <tr> <th class="def-table-code"><a href="/ino/index.php?q=333741&brand=KYB&sort=property_CML2_ARTICLE&method=asc">Код</a></th> <th class="def-table-manufacturer"><a href="/ino/index.php?q=333741&brand=KYB&sort=property_BREND&method=asc">Производитель</a></th> <th class="def-table-title"><a href="/ino/index.php?q=333741&brand=KYB&sort=NAME&method=asc">Название</a></th> <th class="def-table-available"><a href="/ino/index.php?q=333741&brand=KYB&sort=CATALOG_QUANTITY&method=asc">Количество, шт.</a></th> <th class="def-table-delivery"><a href="/ino/index.php?q=333741&brand=KYB&sort=property_CML2_DAYS_DELIVERY&method=asc">Срок поставки, дн.</a></th> <th class="def-table-price"><a href="/ino/index.php?q=333741&brand=KYB&sort=CATALOG_PRICE_1&method=asc">Цена, руб.</a></th> <th class="def-table-buy">В корзину</th> </tr> </thead> <tbody> <tr class="main-tr"><td colspan="7">Результаты для запрошенного номера</td></tr> <tr> <td class="def-table-code" rowspan="3">333741</td> <td class="def-table-manufacturer" rowspan="3">KYB</td> <td class="def-table-title" rowspan="3">Амортизатор подвески передн DACIA: LOGAN 04-</td> <td class="def-table-available W">20 </td> <td class="def-table-delivery W">1</td> <td class="def-table-price W"> 2 245.69 </td> <td class="def-table-buy W"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 20) this.value=20" name="quantity" value="1" id="quantity465828"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity465828').value < 20) BX('quantity465828').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity465828').value > 1) BX('quantity465828').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (20 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card465828"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="465828"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-available W">100 </td> <td class="def-table-delivery W">1</td> <td class="def-table-price W"> 2 239.72 </td> <td class="def-table-buy W"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 100) this.value=100" name="quantity" value="1" id="quantity532351"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity532351').value < 100) BX('quantity532351').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity532351').value > 1) BX('quantity532351').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (100 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card532351"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="532351"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-available W">100 </td> <td class="def-table-delivery W">1</td> <td class="def-table-price W"> 2 245.79 </td> <td class="def-table-buy W"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 100) this.value=100" name="quantity" value="1" id="quantity465829"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity465829').value < 100) BX('quantity465829').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity465829').value > 1) BX('quantity465829').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (100 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card465829"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="465829"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr class="main-tr"><td colspan="7">Аналоги для запрошенного номера</td></tr> <tr> <td class="def-table-code" rowspan="2">ASH7072</td> <td class="def-table-manufacturer" rowspan="2">AUTOMOTOR FRANCE</td> <td class="def-table-title" rowspan="2">Амортизатор RENAULT LOGAN 04- зад.масл.</td> <td class="def-table-available N" style="background-color: rgb(200, 255, 200);">3 </td> <td class="def-table-delivery N" style="background-color: rgb(200, 255, 200);">На складе</td> <td class="def-table-price N" style="background-color: rgb(200, 255, 200);"> 1 250.26 </td> <td class="def-table-buy N" style="background-color: rgb(200, 255, 200);"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 3) this.value=3" name="quantity" value="1" id="quantity120608"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity120608').value < 3) BX('quantity120608').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity120608').value > 1) BX('quantity120608').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (3 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card120608"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="120608"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-available W">2 </td> <td class="def-table-delivery W">1</td> <td class="def-table-price W"> 2 051.05 </td> <td class="def-table-buy W"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 2) this.value=2" name="quantity" value="1" id="quantity350832"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity350832').value < 2) BX('quantity350832').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity350832').value > 1) BX('quantity350832').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (2 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card350832"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="350832"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-code" rowspan="2">ASG7072</td> <td class="def-table-manufacturer" rowspan="2">AUTOMOTOR FRANCE</td> <td class="def-table-title" rowspan="2">Амортизатор RENAULT LOGAN 04- зад.газ.</td> <td class="def-table-available N" style="background-color: rgb(200, 255, 200);">2 </td> <td class="def-table-delivery N" style="background-color: rgb(200, 255, 200);">На складе</td> <td class="def-table-price N" style="background-color: rgb(200, 255, 200);"> 1 250.26 </td> <td class="def-table-buy N" style="background-color: rgb(200, 255, 200);"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 2) this.value=2" name="quantity" value="1" id="quantity120606"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity120606').value < 2) BX('quantity120606').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity120606').value > 1) BX('quantity120606').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (2 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card120606"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="120606"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-available W">5 </td> <td class="def-table-delivery W">1</td> <td class="def-table-price W"> 1 419.67 </td> <td class="def-table-buy W"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 5) this.value=5" name="quantity" value="1" id="quantity350831"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity350831').value < 5) BX('quantity350831').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity350831').value > 1) BX('quantity350831').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (5 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card350831"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="350831"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-code" rowspan="2">PSA333741</td> <td class="def-table-manufacturer" rowspan="2">PATRON</td> <td class="def-table-title" rowspan="2">Амортизатор подвески передн DACIA: LOGAN 04-</td> <td class="def-table-available N" style="background-color: rgb(200, 255, 200);">2 </td> <td class="def-table-delivery N" style="background-color: rgb(200, 255, 200);">На складе</td> <td class="def-table-price N" style="background-color: rgb(200, 255, 200);"> 1 544.33 </td> <td class="def-table-buy N" style="background-color: rgb(200, 255, 200);"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 2) this.value=2" name="quantity" value="1" id="quantity86753"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity86753').value < 2) BX('quantity86753').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity86753').value > 1) BX('quantity86753').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (2 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card86753"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="86753"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> <tr> <td class="def-table-available W">100 </td> <td class="def-table-delivery W">1</td> <td class="def-table-price W"> 1 431.21 </td> <td class="def-table-buy W"> <form action="/ino/index.php?q=333741&brand=KYB" method="post" enctype="multipart/form-data" class="add_form_to_basket"> <div class="count clearfix"> <div class="counter"> <input type="text" class="counter_input" size="3" onblur="if (this.value > 100) this.value=100" name="quantity" value="1" id="quantity350655"> </div> <div class="counter"> <div class="quantity_control"> <a class="PlusList plus" href="javascript:void(0)" onclick="if (BX('quantity350655').value < 100) BX('quantity350655').value++;"></a> <a class="MinusList minus" href="javascript:void(0)" onclick="if (BX('quantity350655').value > 1) BX('quantity350655').value--;"></a> </div> </div> <div class="counter"> <input type="submit" class="btn btn-small" onclick="if (100 > 0){yaCounter12899284.reachGoal('CART'); return true;}else{this.disabled=true; return true;}" name="actionADD2BASKET" value="" title="Добавить в корзину" id="link2card350655"> </div> </div> <div class="some-class"> </div> <input type="hidden" name="action" value="BUY"> <input type="hidden" name="id" value="350655"> <input type="submit" name="actionBUY" value="Купить" style="display:none;"> </form> </td> </tr> </tbody> </table> This html table is formed by the php code of the bitrix component. I have one table, but I need to sort it out separately within the results of the requested number and analogues of the requested number. (that is, from one plate you need to sort two separate plates). I form an array (product ID, number of descendants, ID descendant, company, code, description, cash, delivery time, price) in the form
<? $row_section[$index]['id']=$productID; $row_section[$index]['cell']=array($tovar,$cnt,$productID,$arElement["PROPERTIES"]["CML2_ARTICLE"]["VALUE"],$arElement["PROPERTIES"]["BREND"]["VALUE"],$arElement["NAME"],$n,$arOffer["PROPERTIES"]["CML2_DAYS_DELIVERY"]["VALUE"],$price); $index=$index+1; ?>