mockoon icon indicating copy to clipboard operation
mockoon copied to clipboard

Add a custom helper for sorting array

Open louiskhchan opened this issue 1 year ago • 2 comments

Currently, Mockoon has array helpers like filter and slice. It would be ideal if a sort helper could be added.

Discussion: https://github.com/mockoon/mockoon/discussions/1257

louiskhchan avatar Jan 17 '24 18:01 louiskhchan

@255kb Please assign this to me.

ajatkj avatar Mar 29 '24 07:03 ajatkj

We discussed a bit with @ajatkj and propose the following implementation with two helpers:

  • {{sort 'asc|desc'}} for arrays of strings and numbers.
  • {{sortBy 'keyname' 'asc|desc'}} for arrays of objects.

255kb avatar Mar 29 '24 07:03 255kb

📦 This was released in v8.3.0

255kb avatar Jul 08 '24 14:07 255kb