Sort/OrderBy pipe in Angular 5/6/7/8/9 (updated)

  1. formatting the displayed information
  2. transforming/changing the values without affecting the true data source
  3. restructuring your data, like sorting it.
  1. it first checks if we do have an array, a column/property on basis of which we need to sort & if we do have a sorting order in case if we do not want to sort anything.
  2. another check is to just verify if we have more than one object, otherwise there’s no reason to sort a single object/data.
  3. the orderBy function which takes 3 arguments; (list, column/property, order of sorting)
  4. updated : included a check to verify if it is a 1d array or multi dimensional array & perform sort.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Md Moin

Md Moin

I’m a dev who codes for fun & likes to share my learnings.