I need to write a custom pipe in Angular that takes an array of objects and a variable called order with a value of either ascending or descending as a parameter and then sort the array of objects by a property value.
The data looks something like this:
[
{
"location_type": "KAUPPA",
"postalcode": "100",
"availability": "LIIKETILAN AUKIOLO",
"location": "SUOMALAINEN KIRJAKAUPPA / SISÄKÄYTÄVÄ",
"municipality": "TURKU",
"target_address": "ALEKSANTERINKATU 23",
"availability_details": "",
"coordinates_lon": "24.941095",
"coordinates_lat": "60.168718"
},
{
"location_type": "PANKIN KONTTORI",
"postalcode": "100",
"availability": "ITSEPALVELUALUEEN AUKIOLO",
"location": "NORDEA SENAATINTORI",
"municipality": "VANTAA",
"target_address": "ALEKSANTERINKATU 30",
"availability_details": "ma-su klo 06-22",
"coordinates_lon": "24.950720",
"coordinates_lat": "60.168930"
},
{
"location_type": "TAVARATALO",
"postalcode": "100",
"availability": "LIIKETILAN AUKIOLO",
"location": "STOCKMANN / 8. KERROS",
"municipality": "HELSINKI",
"target_address": "ALEKSANTERINKATU 52",
"availability_details": "",
"coordinates_lon": "24.941870",
"coordinates_lat": "60.168430"
}
]
The objects in the array need to be put into an order by municipality's value.