Reputation: 11
I’m a newbie to Tcl and code writing in general. I have what seems like a simple coding issue that I have about 10 hrs into that I can’t seem to resolve. I have a file that contains a list of nets clk123, n789, clk456, n246…. I need to reorder the list so that the clk* nets appear first when outputted. I can read the files in question and output the contents to the monitor or a file. But, I’m not able to find a way to reorder the list. I’ve spent so much time researching this that I’m now completely confused. Can someone offer a suggestion?
Upvotes: 1
Views: 194
Reputation: 13252
If there's just clk*
and n*
nets, a simple sort should be sufficient:
package require fileutil
proc sort data {
set lines [split $data \n]
set lines [lsort $lines]
join $lines \n
}
::fileutil::updateInPlace thefile.txt sort
Documentation: fileutil package, join, lsort, package, proc, set, split
Upvotes: 1