How to sort any generic collection using bubble sort and check if it's sorted?
<p>I have to implement a method which sorts any kind of collection by using bubble sort and after that to test if it really is sorted how can I accomplish this by using generics ?</p>

<p>This is what i've done so far :</p>

<pre><code>public class SortManager {
    public &lt;T extends Collection&gt; void bubbleSort(T collection) {
        //sort a given collection

    }

    public &lt;T extends Collection&lt;?&gt;&gt; boolean isSorted(T collection) {
        //need to check if a given collection is sorted
        return false;
    }
}
</code></pre>

<p>And the test:</p>

<pre><code>@Test
    public void testIfTheCollectionsAreSorted() {
        ArrayList&lt;Integer&gt; integers = new ArrayList&lt;&gt;();

        SortManager sortManager = new SortManager();
        sortManager.bubbleSort(integers);
        assertTrue(sortManager.isSorted(integers));
    }
</code></pre>