Thursday 1 June 2017

Ordering the content of on array with NodeJS and lodash

I have an array like this:

[
  'pathOne/pathTwo/contentOne',
  'pathOne/pathThree/pathFour/contentTwo',
  'pathOne/pathThree/contentFive',
  'pathFive/pathThree/contentThree',
  'pathOne/pathTwo/contentFour'
]

I'm looking to have a string in alpha order and content first before the next sub-level:

pathFive

  • pathThree
    • contentThree

pathOne

  • pathThree
    • contentFive (Content before sub-level)
    • pathFour
    • contentTwo (One more level)
  • pathTwo
    • contentFour
    • contentOne

I started to get this inside an array with lodash to do easiest operation on it but i couldn't get this.



via Tolatola

No comments:

Post a Comment