Node Script

Sort Number Array

Downloads: 28
Download
Ads Support FTD

Description

Simple Sort Number Array Node Script

//
// SortNumberArrayNode.ts
// Sorts a float[] array ascending or descending.
// Written by @Fusedthreed – https://FusedThreeD.com
//

@customNode()
export class SortNumberArrayNode extends BasicScriptNode {
  @input('float[]')
  unsorted: number[];

  @input('bool')
  descending: boolean = false;

  @output('float[]')
  sorted: number[];


  execute() {

        if(this.descending === false)
        {
          this.sorted = this.unsorted.sort((a,b) => a - b)
        }else{
          this.sorted = this.unsorted.sort((a, b) => b - a)
        }
        
  }
}
Ads Support FTD