Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created April 9, 2017 11:35
Show Gist options
  • Save bekatom/7a178f0bd214e2db193a9a66f5e90dc7 to your computer and use it in GitHub Desktop.
Save bekatom/7a178f0bd214e2db193a9a66f5e90dc7 to your computer and use it in GitHub Desktop.
createAlphabetSorting with lodash
import _ from 'lodash'
/**
* Create Alpavet data structure from list of objects like : [ A : {}, B : {}]
* @param {*} list
*/
export const createAlphabetSorting = list =>
_.groupBy(
_.sortBy(list, [i => i.firstName.toLowerCase()]),
item => item.firstName.charAt(0).toUpperCase())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment