For the order of subtasks within a task, yes, use the setParent endpoint as documented; let me know if you have any questions about it.
To set the order of a top-level task within a project, use the Add project to a task endpoint: set the project parameter to the gid of the project that the task is already in, set insert_after or insert_before to the gid of the other task you want to be relative to the target task, and omit the section parameter.