AnsweredAssumed Answered

How to sort a field using a wildcard for its name

Question asked by kostas_ptr88 on May 24, 2015
Latest reply on May 25, 2015 by kostas_ptr88

Hello everyone, i have a problem with my point shapefiles in which i implement a big procession. The problem is that although all the shapefiles have the same columns there is one which starts with "P500" AND continues differently to each one which in some it is sort ascended and in others sort descended. Is there a way with python where i can sort ascend this column for every point file by using "P500" as wildcard. I tried it but my FID changed also causing me problems.

 

In some shp i have this   and in some other this(problem)      and i want it to be like the first two columns

FID     PNT500B                    FID     PNT500C20            

0          0                                   0          3

1          1                                   1          2

2          2                                   2          1

3          3                                   3          0

 

 

 

This is the code i have written but it doesn't work properly

 

import arcpy
from arcpy import env
arcpy.env.workspace = "c:/Bo/Well/Point"
fcs = arcpy.ListFeatureClasses("samp*", "point")
fields = arcpy.ListFields(fcs, "P500*", "Double")
for fc in fcs:
   for fiel in fields:
  arcpy.Sort_management(fc, fc_sort, [[fiel, "ASCENDING"]])

Outcomes