sort a file

BlitzMax Forums/BlitzMax Beginners Area/sort a file

hub(Posted 2007) [#1]
hi !
i've a .bmx source file, i need sort it. Is there a tool to do this ?

The file contains this kind of lines :

TL.Create (566,"bullet ","")
TL.Create (030,"ship ","")
TL.Create (079,"weapon ","")


i want just sort by numbers ascending like this.

TL.Create (030,"ship ","")
TL.Create (079,"weapon ","")
TL.Create (566,"bullet ","")


Thanks for your ideas


Brucey(Posted 2007) [#2]
Would it not be simpler to have the data stored in a text file (inbin'd if you like), and parse it at runtime?
That way you wouldn't have a need to sort source-code :-p

How's about this:

sort -n myfile.bmx > newfile.bmx


example:
xxxxxxxxxx:~> cat sorttest.txt
TL.Create (566,"bullet ","")
TL.Create (030,"ship ","")
TL.Create (079,"weapon ","")

xxxxxxxxxx:~> sort -n sorttest.txt
TL.Create (030,"ship ","")
TL.Create (079,"weapon ","")
TL.Create (566,"bullet ","")



hub(Posted 2007) [#3]
Thanks brucey, the os sort function do the job !


Grey Alien(Posted 2007) [#4]
nice OS calls!