Question: I have HTML that looks like this:

```
    <table  cellspacing='0' border='0' width='100%'>
    <col align='left' />
    <tr>
    <td align='left'><font color='#FF0000'>Programming</font></td>
    </tr>
    </table>
    <table  cellspacing='0' border='0' width='100%'>
    <col align='left' />
    <col align='right' />
    <tr>
    <td align='left'><font color='#000000'>A1000</font></td>
    <td align='right'><font color='#008000'>D.Rogers</font></td>
    </tr>
    </table>

```

It is locally stored. I am trying to figure out how to data scrape "Programming","A1000" and "D.Rogers. How can I do this using Java and Jsoup?

Answer: 
`Array.protoype.sort` is not guaranteed to be *stable*. No guarantees are made that equal elements will retain their original order.

> 
> The `sort()` method sorts the elements of an array in place and returns the array. **The sort is not necessarily [stable](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability).** The default sort order is according to string Unicode code points.
> 
> 
> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort>
> 
> 
>
If you want to sort by ascending it should be the comparator function should return a - b not a.length - b.length because a.length - b.length the result will always be zero for all the alphabets of length 1. The result will be different for ['ab', 'a'] will produce ['a', 'ab'] because the length of first element in array is lesser than second element.

```
function longest(arr) {
  return arr.sort( (a,b) => {
    return a - b;
  });
}

```