Sorting of nested fields

if an attribute in a record has list of objects as shown below ,

customSize: [
{ size: “small”, sequence: “39” }
{ size: “medium”, sequence: “0” }
{ size: “large”, sequence: “25” }
{ size: “X-Large”, sequence: “25” }
]

How can we sort the records based on the sequence number depending the size?

For example, if i pick small, then the products which are having that size would be listed, as shown above since it is having multiple sequence numbers in the same record. I need to sort the results for size small based on the sequence number.

Likewise, if i select large the records should sort based on the corresponding sequence number.