Hello, I have a list like this:
[
%{
index: 1,
params: %{
id: "test1",
title: "test of one",
width: "col-sm-12"
},
type: "Heading"
},
%{
index: 3,
params: %{
id: "test3",
title: "test of one",
width: "col-sm-12"
},
type: "Heading"
},
%{
index: 5,
params: %{
id: "test5",
title: "test of one",
width: "col-sm-12"
},
type: "Heading"
},
]
and I want to change all index number and sort them but with new index which starts 0 like this
[
%{
index: 0,
params: %{
id: "test1",
title: "test of one",
width: "col-sm-12"
},
type: "Heading"
},
%{
index: 1,
params: %{
id: "test4",
title: "test of one",
width: "col-sm-12"
},
type: "Heading"
},
%{
index: 2,
params: %{
id: "test5",
title: "test of one",
width: "col-sm-12"
},
type: "Heading"
},
]
I need this because maybe a map is deleted in a list and the map deleted index will be null and I want to re-index all the map after every deleting
Thanks