Thursday, 18 May 2017

how i can sort user by role in javascript?

I'm running Rocket Chat system in developer version and I need to sort users by role not by online status because the default sort is

    // show online users first.
    // sortBy is stable, so we can do this
    users = _.sortBy(users, u => u.status == null);

i need to change this code to sort by role level and this example for user data in users.json

{
  "type" : "user", 
  "status" : "offline", 
  "active" : true, 
  "name" : "Super", 
  "_updatedAt" : ISODate("2017-05-16T15:10:30.559+0000"), 
  "roles" : [
      "admin"
  ]
}



via Ahmed El Sheikh

No comments:

Post a Comment