Maintain style order with REST API call

My team has a custom Figma Plugin that pulls styles from one file into another (see my note* below on why we don’t use the native style sharing functionality). We utilize the REST API from within the plugin in order to gather the styles, and I’m wondering if it’s possible to maintain the style order in cases where styles are deliberately not alphabetical? The JSON from the REST API does not maintain the order, and I’ve yet to figure out how sort_position is useful (I’d love some more documentation on what it is and how to use it). The styles are organized into nested folders.

  • We’re defining foundational design tokens in one file, then pulling them into a more robust design system file which is then shared with product teams. In order to share the styles with product teams, and maintain an actual link to the original foundational file, we had to build our own plugin (as the native sharing doesn’t maintain the link two levels deep).