sort in descending if obj of array is number.else in ascending order. in angular javascript

i have an array of objects. if each obj consists of year followed by title. then year should be in descending order and title should be in ascending order.

ex:
i have an array like
[2018 Apple,2017 Car , 2022 Ball ,2021 Dog,2021 Box,2018 Bat];

my sorting requirement would be like

[2022 Ball, 2021 Box , 2021 Dog , 2018 Apple ,2018 Bat,2017Car]

if you observe for 2021 and 2018 their titles are appearing in ascending and all years are appearing in descending.

in javascript /angular!