Closed Raruto closed 2 months ago
Be able to sort the the following values by "formatted" field value instead of by field key:
https://v37.g3wsuite.it/vector/api/data/qdjango/97/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/?fformatter=address&ordering=address
// current behavior "data": [ [ "A101", "Via Sallustio Bandini" ], [ "A102", "Via Atto Vannucci" ], [ "A103", "Via Alfredo Oriani gia' Via Vecchia" ], [ "A106", "Piazza Pietro Leopoldo" ], [ "A107", "Via Ubaldo Montelatici" ], [ "A108", "Via Giandomenico Romagnosi" ], [ "B002", "Via Giovanni Lampredi" ], [ "C106", "Via Pietro Cironi" ], [ "C107", "Via Pietro Corridoni" ] ],
Introduce a new parameter or change the ordering behavior so that response can be like following:
ordering
// desired behavior "data": [ [ "A106", "Piazza Pietro Leopoldo" ], [ "A103", "Via Alfredo Oriani gia' Via Vecchia" ], [ "A102", "Via Atto Vannucci" ], [ "A108", "Via Giandomenico Romagnosi" ], [ "B002", "Via Giovanni Lampredi" ], [ "C106", "Via Pietro Cironi" ], [ "C107", "Via Pietro Corridoni" ], [ "A101", "Via Sallustio Bandini" ], [ "A107", "Via Ubaldo Montelatici" ] ],
NB the sorting algo must also take into account numeric, null and boolean values (see below)
Formatted values can be sorted on client-side, but this make every API calls code even more complex/unreliable:
fetch('https://v37.g3wsuite.it/vector/api/data/qdjango/97/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/?fformatter=address' /* + '&ordering=address' */) .then(d => d.json()) // sorted by fformatter .then(d => d.data.sort((a, b) => `${a[1]}`.localeCompare(b[1], undefined, 'number' === typeof a[1] ? { numeric: true } : { sensitivity: 'base' })))
Checklist
Motivation
Be able to sort the the following values by "formatted" field value instead of by field key:
https://v37.g3wsuite.it/vector/api/data/qdjango/97/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/?fformatter=address&ordering=address
Suggested solution
Introduce a new parameter or change the
ordering
behavior so that response can be like following:NB the sorting algo must also take into account numeric, null and boolean values (see below)
Alternatives considered
Formatted values can be sorted on client-side, but this make every API calls code even more complex/unreliable: