Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sort Array by number from string
#2
If possible, don't use 2D arrays. Use only when the number of columns is unknown.

Macro Macro21
Code:
Copy      Help
out
type PRODUCTN str'product int'n
ARRAY(PRODUCTN) a.create(3)
a[0].product="Product1"
a[0].n=95
a[1].product="Product2"
a[1].n=112
a[2].product="Product3"
a[2].n=5

a.sort(1 sub.sortwordHits)

int n
for n 0 a.len
,out F"product={a[n].product}, n={a[n].n}"


#sub sortwordHits
function# param PRODUCTN&a PRODUCTN&b
if(a.n<b.n) ret -1
if(a.n>b.n) ret 1


Messages In This Thread
Sort Array by number from string - by TheDane - 08-01-2018, 01:22 PM
RE: Sort Array by number from string - by Gintaras - 08-01-2018, 05:53 PM
RE: Sort Array by number from string - by TheDane - 08-02-2018, 06:33 AM
RE: Sort Array by number from string - by Kevin - 08-02-2018, 08:16 AM
RE: Sort Array by number from string - by TheDane - 08-08-2018, 10:21 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)