This should be possible by adjusting your sort condition. Instead of lValue.categoryName < rValue.categoryNameyou could write something like this:
(lValue.categoryName == price || rValue.categoryName == price) || lValue.categoryName < rValue.categoryName
or
!(lValue.categoryName == price || rValue.categoryName == price) || lValue.categoryName < rValue.categoryName
This is not correct code yet and I didn't validate the conditions, but I hope you get the idea.
lValue.categoryName < rValue.categoryName is the sort condition the .sort-function uses to decide in which order the elements should appear.
You can use very complex conditions or even a function deciding the order of two items by returning true or false depending on the order you want the two compared elements to appear.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: