Help me please. List of nodes.
<list>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
and so on...
</list>
It is necessary to divide the list of equal parts "n" (an arbitrary number).
If the number of nodes is not divided equally, then let the last set of nodes contain the remainder of the division.
For example, if the input list contains 33 elements, and the output should contain 4 parts with evenly distributed elements. At the output, you can get 3 parts of up to 9 elements and one part with 6 elements in a total of 33.
input
<ul>
<li>1</li>
<li>2</li>
...
<li>33</li>
</ul>
Output
<ul>
<li>1</li>
<li>2</li>
...
<li>9</li>
</ul>
<ul>
<li>10</li>
<li>11</li>
...
<li>18</li>
</ul>
<ul>
<li>19</li>
<li>11</li>
...
<li>27</li>
</ul>
<ul>
<li>28</li>
<li>30</li>
...
<li>33</li>
</ul>
Divided into 4 columns.
source
share