Nety
Nety

Reputation: 129

Sort nested list

I found this code to sort nested list.

  to-report test 
  let z [[2 3] [1 9] [3 1] ] 
  report sort-by [(first ?1) < (first ?2)] z 
  end 

What is first ?1 and first ?2 in this formula. It says that they are not defined as variables.

Upvotes: 1

Views: 355

Answers (1)

Charles
Charles

Reputation: 4168

Are you perhaps using NetLogo v6.0? Your code works in v5.3.1, but v6.0 uses anonymous reporters. It would look like:

to-report test 
  let z [[2 3] [1 9] [3 1] ] 
  report sort-by [[list1 list2] -> first list1 < first list2] z 
end 

Charles

Upvotes: 2

Related Questions