I need help sorting a table by both numbers and words obtained from an API. The words sort correctly, but the numbers do not. How can I convert the string values to numbers?
Here is the API call I am using:
axios.get(`/json/secciones`+ tienda +`.json`)
.then(response => {this.userInfo = response.data;})
.catch(e => {this.errors.push(e);});
The API returns the following data:
[
{
"id_store": 2,
"id_section": 1,
"desc_section": "MATERIALES DE CONSTRUCCION",
"id_rule": 1,
"sale_potential": "79413.5525190617"
},
{
"id_store": 2,
"id_section": 2,
"desc_section": "CARPINTERIA Y MADERA",
"id_rule": 1,
"sale_potential": "74704.3439572555"
},
{
"id_store": 2,
"id_section": 3,
"desc_section": "ELECTR-FONTAN-CALOR",
"id_rule": 1,
"sale_potential": "101255.89182774"
},
{
"id_store": 2,
"id_section": 4,
"desc_section": "HERRAMIENTA",
"id_rule": 1,
"sale_potential": "36969.8901028374"
}
]
How can I modify it to have the sale_potential values as numbers instead of strings?
[
{
"id_store": 2,
"id_section": 1,
"desc_section": "MATERIALES DE CONSTRUCCION",
"id_rule": 1,
"sale_potential": 79413.5525190617
},
{
"id_store": 2,
"id_section": 2,
"desc_section": "CARPINTERIA Y MADERA",
"id_rule": 1,
"sale_potential": 74704.3439572555
},
{
"id_store": 2,
"id_section": 3,
"desc_section": "ELECTR-FONTAN-CALOR",
"id_rule": 1,
"sale_potential": 101255.89182774
},
{
"id_store": 2,
"id_section": 4,
"desc_section": "HERRAMIENTA",
"id_rule": 1,
"sale_potential": 36969.8901028374
}
]