error incompatible types: Comparable<T> cannot be converted to T

Viewed 6052

I'm not sure what is going on. The method works pereclty with an array but if I use a list... well.

I really hope you can help me.

public static <T> void ordenaSeleccion(List<? extends Comparable<T>> datos)
{
    Object aux;
    int menor;

    for (int i = 0; i < datos.size(); i++) {
        menor = i;

        for (int j = i + 1; j < datos.size(); j++) {
            if (datos.get(menor).compareTo(datos.get(j)) > 0) { //error line
                menor = j;
            }
        }

        if (menor != i) {
            aux = datos.get(i);
            datos.set(i, datos.get(menor));
            datos.set(menor, aux);
        }

    }
}

this is the error:

enter image description here

2 Answers
Related