Skip to main content
Bumped by Community user
code formatting
Source Link
J. Monticolo
  • 15.9k
  • 1
  • 29
  • 65

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What iI have:

[ID,  Layer,  Meas],
[1,     1,     3],
[2,     1,     2],
[3,     1,     1],  
[4,     1,     5],
[5,     2,     3],
[6,     2,     2],
[7,     2,     5], 
[8,     3,     3],
[9,     3,     2],
[10,     3,     1],  
[11,     3,     5]

What iI want:

[ID,  Layer,  Meas],
[3,     1,     1],
[2,     1,     2],
[1,     1,     3],
[4,     1,     5],
[7,     2,     5], 
[5,     2,     3],
[6,     2,     2],
[10,     3,     1], 
[9,     3,     2],
[8,     3,     3],
[11,     3,     5]

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What i have:

[ID,  Layer,  Meas],
[1,     1,     3],
[2,     1,     2],
[3,     1,     1],  
[4,     1,     5],
[5,     2,     3],
[6,     2,     2],
[7,     2,     5], 
[8,     3,     3],
[9,     3,     2],
[10,     3,     1],  
[11,     3,     5]

What i want:

[ID,  Layer,  Meas],
[3,     1,     1],
[2,     1,     2],
[1,     1,     3],
[4,     1,     5],
[7,     2,     5], 
[5,     2,     3],
[6,     2,     2],
[10,     3,     1], 
[9,     3,     2],
[8,     3,     3],
[11,     3,     5]

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What I have:

[ID,  Layer,  Meas],
[1,     1,     3],
[2,     1,     2],
[3,     1,     1],  
[4,     1,     5],
[5,     2,     3],
[6,     2,     2],
[7,     2,     5], 
[8,     3,     3],
[9,     3,     2],
[10,     3,     1],  
[11,     3,     5]

What I want:

[ID,  Layer,  Meas],
[3,     1,     1],
[2,     1,     2],
[1,     1,     3],
[4,     1,     5],
[7,     2,     5], 
[5,     2,     3],
[6,     2,     2],
[10,     3,     1], 
[9,     3,     2],
[8,     3,     3],
[11,     3,     5]
imporved formatting
Source Link
tinlyx
  • 11.2k
  • 18
  • 76
  • 127

Sorting a table based in a anon if-then statement

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What i have:
[ID, Layer, Meas], [1, 1, 3], [2, 1, 2], [3, 1, 1],
[4, 1, 5], [5, 2, 3], [6, 2, 2], [7, 2, 5], [8, 3, 3], [9, 3, 2], [10, 3, 1],
[11, 3, 5]

[ID,  Layer,  Meas],
[1,     1,     3],
[2,     1,     2],
[3,     1,     1],  
[4,     1,     5],
[5,     2,     3],
[6,     2,     2],
[7,     2,     5], 
[8,     3,     3],
[9,     3,     2],
[10,     3,     1],  
[11,     3,     5]

What i want:
[ID, Layer, Meas], [3, 1, 1], [2, 1, 2], [1, 1, 3], [4, 1, 5], [7, 2, 5], [5, 2, 3], [6, 2, 2], [10, 3, 1], [9, 3, 2], [8, 3, 3], [11, 3, 5]

[ID,  Layer,  Meas],
[3,     1,     1],
[2,     1,     2],
[1,     1,     3],
[4,     1,     5],
[7,     2,     5], 
[5,     2,     3],
[6,     2,     2],
[10,     3,     1], 
[9,     3,     2],
[8,     3,     3],
[11,     3,     5]

Sorting a table based in a an if-then statement

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What i have:
[ID, Layer, Meas], [1, 1, 3], [2, 1, 2], [3, 1, 1],
[4, 1, 5], [5, 2, 3], [6, 2, 2], [7, 2, 5], [8, 3, 3], [9, 3, 2], [10, 3, 1],
[11, 3, 5]

What i want:
[ID, Layer, Meas], [3, 1, 1], [2, 1, 2], [1, 1, 3], [4, 1, 5], [7, 2, 5], [5, 2, 3], [6, 2, 2], [10, 3, 1], [9, 3, 2], [8, 3, 3], [11, 3, 5]

Sorting a table based on if-then statement

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What i have:

[ID,  Layer,  Meas],
[1,     1,     3],
[2,     1,     2],
[3,     1,     1],  
[4,     1,     5],
[5,     2,     3],
[6,     2,     2],
[7,     2,     5], 
[8,     3,     3],
[9,     3,     2],
[10,     3,     1],  
[11,     3,     5]

What i want:

[ID,  Layer,  Meas],
[3,     1,     1],
[2,     1,     2],
[1,     1,     3],
[4,     1,     5],
[7,     2,     5], 
[5,     2,     3],
[6,     2,     2],
[10,     3,     1], 
[9,     3,     2],
[8,     3,     3],
[11,     3,     5]
Source Link

Sorting a table based in a an if-then statement

I have a large table with two attribute fields "layers" and "Meas" both contain numbers, I would like to sort "Meas" in the odd numbered "layers" in ascending order, and "Meas" in the even numbered "layers" in Descending order. This would be part of a larger model in modelbuilder. I am using Arc Desktop, so "If Value Is" tool is not available.

This feels like it should be easy to do, however I have tried unsuccessfully to code something in python and am at a loss about how to approach the issue, any suggestions?

What i have:
[ID, Layer, Meas], [1, 1, 3], [2, 1, 2], [3, 1, 1],
[4, 1, 5], [5, 2, 3], [6, 2, 2], [7, 2, 5], [8, 3, 3], [9, 3, 2], [10, 3, 1],
[11, 3, 5]

What i want:
[ID, Layer, Meas], [3, 1, 1], [2, 1, 2], [1, 1, 3], [4, 1, 5], [7, 2, 5], [5, 2, 3], [6, 2, 2], [10, 3, 1], [9, 3, 2], [8, 3, 3], [11, 3, 5]