What i trying to achieve is my Set having the same order as my List which is chaging when i assign value from List to Set. Here is what i do :
// in here my array still showing same as my submited front end
List<ShipmentAddressGroupingDtDto> submitedShipmentAddressGroupingDtDto = shipmentAddressGroupingDto.getShipmentAddressGroupingDtDto();
//in here my array start changing, it's not the same order again as my object above
Set<ShipmentAddressGroupingDtDto> setShipmentAddressGroupingDtDto = new HashSet(submitedShipmentAddressGroupingDtDto);
List<ShipmentAddressGroupingDtDto> shipmentAddressGroupingDtDto = new ArrayList<ShipmentAddressGroupingDtDto>(setShipmentAddressGroupingDtDto);
here is my value for submitedShipmentAddressGroupingDtDto :
[
"id": 0,
"address": "Jl. Imam Bonjol",
"isActive": true,
"partnerShipmentId": 1
],
[
"id": 0,
"address": "Jl. Imam Bonjol",
"isActive": true,
"partnerShipmentId": 2
],
[
"id": 0,
"address": "Jl. Imam Bonjol",
"isActive": true,
"partnerShipmentId": 4
],
[
"id": 0,
"address": "Jl. Imam Bonjolx",
"isActive": true,
"partnerShipmentId": 7
]
and what i saw in debug mode, in my setShipmentAddressGroupingDtDto is like this :
[
"id": 0,
"address": "Jl. Imam Bonjol",
"isActive": true,
"partnerShipmentId": 2
],
[
"id": 0,
"address": "Jl. Imam Bonjolx",
"isActive": true,
"partnerShipmentId": 7
],
[
"id": 0,
"address": "Jl. Imam Bonjol",
"isActive": true,
"partnerShipmentId": 1
],
[
"id": 0,
"address": "Jl. Imam Bonjol",
"isActive": true,
"partnerShipmentId": 4
]
How do i prevent Set ordering my List? or if i can't prevent that, how can i sort it as my submited value?