Optimise tinydir_open_sorted (fixes #6)

tinydir_open_sorted to count files and allocate once.
Previous implementation was very inefficient, reallocating
every time the size grows.

A check is added to make sure we do not do a buffer
overflow in case the number of files grows between when we
count the number of files to when we read the files.