Jump to content

Sort internal table with Iron Python


Ivan Fabrizio

Recommended Posts

Hi all,

I have code below that is working fine, but before the last "For" statement I would like to first sort the table before looping.

I've already tried with .sort() but I'm not getting the desired outcome.

Is anyone able to help on that

Thanks in advance.

Ivan

table=Document.Data.Tables["My_Table"]

# === MONDAY ===

monday='Monday'

#where clause

rowSelection=table.Select("Eligible_Day_for_Analysis='"+monday+"'")

# Create a cursor to the Column we wish to get the values from

headerMon = DataValueCursor.CreateFormatted(table.Columns["Header_Date"])

materialMon = DataValueCursor.CreateFormatted(table.Columns["MaterialNo"])

orderNoMon = DataValueCursor.CreateFormatted(table.Columns["Order_No"])

mrpCNameMon = DataValueCursor.CreateFormatted(table.Columns["MRP_Controller_Desc"])

priorityMon = DataValueCursor.CreateFormatted(table.Columns["Day"])

# Need to sort by "priorityMon" before looping

for row in table.GetRows(rowSelection.AsIndexSet(), materialMon, orderNoMon, mrpCNameMon, priorityMon):

rowIndex = row.Index

material = materialMon.CurrentValue

orderNo = orderNoMon.CurrentValue

mrpCName = mrpCNameMon.CurrentValue

priority = priorityMon.CurrentValue

print material, orderNo, mrpCName, priorityMon

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...