Customizing duplication of tasks

Hello. When i duplicate /clone a task(here riveting1) it appears just below the task that is being duplicated. I want whenever i duplicate a task it should appear below the last task of particular group (here it should be below riveting3) Just to differentiate, i have shown duplicated riveting 1 in bold. Thank you

Gantt doesn’t have a built-in way to clone tasks. But it has the API that allows you to do that.
When you create a deep copy of a task object with the copy method, the cloned object has the same properties as the initial task. Then, that cloned object is added with the addTask method. In that method, you can specify the task position in the branch with the third parameter:
If you don’t specify the third parameter, the task will be added at the bottom of the branch.
Here is an example in the snippet: