47.customArraySort

Write a function named customArraySort that receives 2 parameters:

  • an Array of objects, each with 2 properties:

    • id: string
    • age: number
  • currentUserId: string

The function should return a new array that contains all elements, but sorted in a special order:

  1. Current user
  2. All users between 35 (inclusive) - 50 (exclusive)
  3. All users under 18 (exclusive)
  4. All users over 50 (inclusive)
  5. All users between 18 (inclusive) - 35 (exclusive)

Inside every interval, the users are sorted descending by age.

Example 1

Input

users

=

currentUserId

=

Output