added a sort direction to the sort (by adding a minus sign in front of the sortfield)
how about sort.startswith('-') and then strip
A compromise? ;-)
if sort: if sort.startswith('-'): direction = -1 sort = sort[1:] else: direction = 1
I actually asked chatGPT about it. And this it what it gives as advice.
startswith is indeed clearer.
But 'strip' removes all hyphens, that may not be desirable... like when the fieldname contains a hyphen. When only the first hyphen has to be removed it advices to slice it.
you can do lstrip
okay, you're the boss... lstrip it is
eheeh sorry
how about sort.startswith('-') and then strip
A compromise? ;-)
I actually asked chatGPT about it. And this it what it gives as advice.
startswith is indeed clearer.
But 'strip' removes all hyphens, that may not be desirable... like when the fieldname contains a hyphen. When only the first hyphen has to be removed it advices to slice it.
you can do lstrip
okay, you're the boss... lstrip it is
eheeh sorry