How can I sort some data in ascending order?
I've looped over several products to grab this (it should be noted that these could change to any number), here's the unsorted data:
- 10mg
- 100mg
- 500mg
- 1 gram
- 30mg
- 300mg
- 1.5 gram
- 3 gram
This is what I've tried but it doesn't output anything:
<select>
<?php $uniquePids = array_unique($results);
$results = sort($uniquePids);
foreach ( $results as $result ) { ?>
<option value="<?php echo $result; ?>"><?php echo $result; ?></option>
<?php } ?>
</select>
How can I sort it to be 10mg, 30mg, 100mg etc