# Assign values to strings for sorting

**URL:** https://community.riskscape.org.nz/t/assign-values-to-strings-for-sorting/213
**Category:** Community
**Created:** [10 March 2025 00:18 UTC](https://community.riskscape.org.nz/t/assign-values-to-strings-for-sorting/213 "2025-03-10T00:18:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![JPowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@JPowell](https://community.riskscape.org.nz/u/JPowell)
#### Post date: [10 March 2025 00:18 UTC](https://community.riskscape.org.nz/t/assign-values-to-strings-for-sorting/213/1 "2025-03-10T00:18:02Z")

</div>

I have an attribute showing the damage to parts of a building using text and I would like to be able to group by the building and get the maximum damage level for any part of the building.  
The ordering of the damage levels is  
`['none','low','moderate','significant','extreme'] `  
so I would like

```auto
riskscape expression eval "max(['moderate','significant','extreme','low'])

```

to return ‘extreme’, but currently it returns ‘low’.  
Is this possible or do I need to convert the damage levels to integers and then back to strings after grouping?

---

<div class="post-metadata">

### Author: ![timbeale](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timbeale](https://community.riskscape.org.nz/u/timbeale)
#### Post date: [10 March 2025 03:37 UTC](https://community.riskscape.org.nz/t/assign-values-to-strings-for-sorting/213/2 "2025-03-10T03:37:51Z")

</div>

Hi John,

Good question. Using `max()` to with string inputs like that isn’t something that is commonly done in RiskScape, and there is actually a bug in our backlog for it not working correctly (ticket #871). So my advice would be to work in integers and then convert them back to strings later.

Cheers,  
Tim
