Discussion posts and replies are publicly visible
I would rather use build in function todatasubset which gives you an option to sort. Build in function will be faster that custom code.
docs.appian.com/.../fnc_scripting_todatasubset.html
it is directly converting sorting asc and desc , i expected interchange two values step by step bubble sort order