How to use Javascript to sort td into a specific th?

For example I have th with dates

<tr>
<th>20</th>
<th>21</th>
<th>22</th>
</tr>

and I have a group of data that I want to sort them, and place them into a specific th according to the date, what should I do? for example, if I have a data that contain dates of 20, I want to put it in to 20, how can I do that with JS?