Can't manage to sort a file and display time & date on a LCD screen.

but what about pin 4?

What about it? You told the SD class that pin 4 was it's pin to own. Don't touch it.

It works half of the time.

Which half?