We use two rules when we build pivot table (html, excel):
1. Order custom calculations in Html Pivot Table and Excel Pivot Table correponds to the order in "Data" area.
2. If you create custom set that includes custom calculations and after that use this custom set in "Rows" or "Columns" area so the sequence order is defined by custom calculations order usage in your custom set.
In general your pivot table in html should be the same pivot table as in excel. Do you have different pivot tables?