In the getValueAt() method you are retrieving the data from the datos object.
Documento doc = datos[rowIndex].getDocumento();
So the row count should be based on the number of rows in the datos object.
public int getRowCount() {
//return heap.getNumNodos();
return datos.length;
}
The getValueAt() method should NOT be sorting the data. The data in the model should already be sorted. Either sort it externally or sort it when you create the model. That is the getValueAt() method should not be changing the structure of the data. Also every time you change the data you would need to resort.