AnsweredAssumed Answered

Sorted arcpy.da.SearchCursor (sort of)

Question asked by jamesfreddyc on Oct 9, 2018
Latest reply on Oct 9, 2018 by jamesfreddyc

I just can't stand Stackexchange so asking some familiar folks around here for some assistance with rearranging a dictionary that I'm building from an arcpy.da.SearchCursor.  Not really arcpy-specific that I need help with -- what I need is to take this dictionary:

 

{
  "junctionMatrix": [
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1A",
      "juncB": "S-1B",
      "juncDistance": 5475.69
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1B",
      "juncB": "S-1A",
      "juncDistance": 5475.69
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1A",
      "juncB": "S-1C",
      "juncDistance": 8140.32
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1C",
      "juncB": "S-1A",
      "juncDistance": 8140.32
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1B",
      "juncB": "S-1C",
      "juncDistance": 6891.71
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1C",
      "juncB": "S-1B",
      "juncDistance": 6891.71
    }
  ]
}

 

...and rearrange so that values are sorted in this manner:

 

{
  "junctionMatrix": [
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1A",
      "juncB": "S-1B",
      "juncDistance": 5475.69
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1A",
      "juncB": "S-1C",
      "juncDistance": 6891.71
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1B",
      "juncB": "S-1A",
      "juncDistance": 5475.69
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1B",
      "juncB": "S-1C",
      "juncDistance": 6891.71
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1C",
      "juncB": "S-1A",
      "juncDistance": 8140.32
    },
    {
      "WCU": "STA1E_CELL_7",
      "juncA": "S-1C",
      "juncB": "S-1B",
      "juncDistance": 6891.71
    }
  ]
}

 

Any suggestions are appreciated!

Outcomes