How to specify widget order or css name via script?

If you want to change the orders, you can use the filter sidebars_widgets, the argument to which is an array of all the widget ids and their locations. You can change the id positions in that array as per your need.