: for i:=1 to filesize(form3.vidvdfile) do
Are you sure filesize(form3.vidvdfile) return always the maximum index of videos - 1?
if it doesn't, there could be problems in the next line...
: if videos[i]<=videos[i+i] then
: until sorted=true;
This is some kind of bubble-Sort. Sorting algorithms are well researched, I would suggest you search the Internet for it.
: the problem is that some of the array values contain a 0 and when the array compares a 0 with a 0 it keeps going.
Yes, your algorithm cannot deal with equal values... They get swapped over and over.
Easy fix: replace "less or equal" with "less than" in the comparison.