Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sort by column
#1
How can i sort "a" by column 4

a=
sdfdsfas 1243123 asdfs 2 asdfsdf
sdfdsfas 234123 asdfs 4 asdfsdf
sdfdsfas 89823 asdfs 1 asdfsdf
sdfdsfas 1943345 asdfs 3 asdfsdf
sdfasdffas 2343345 asdfs 10 asdfsdf

[...]

a=
sdfdsfas 89823 asdfs 1 asdfsdf
sdfdsfas 1243123 asdfs 2 asdfsdf
sdfdsfas 1943345 asdfs 3 asdfsdf
sdfdsfas 234123 asdfs 4 asdfsdf
sdfasdffas 2343345 asdfs 10 asdfsdf
#2
Same as sorting lines, but in callback function instead of strcmp string from beginning, findt needed column and strcmp it. Also, to compare numbers so that 10 would be after 2, val to numbers and < > numbers instead of strcmp strings.
#3
can you help me with the callback function?
#4
Code:
Copy      Help
function[c] $&s1 $&s2

int i1=findt(s1 3 " ")
int i2=findt(s2 3 " ")
if(i1<0 or i2<0) ret

i1=val(s1+i1)
i2=val(s2+i2)
if(i1<i2) ret -1
if(i1>i2) ret 1
#5
Thank you.

You makes it so easy...


Forum Jump:


Users browsing this thread: 1 Guest(s)