ArcPy and ArcGIS Pro 2.3.2
Was anybody here successfull in setting a list of sorted Item objects based on features count to the ItemGroup (Unique Value Renderer)? Everytime I try it, I receive an error saying that such attribute cannot be set or ArcGIS Pro crashes unexpectedly. According to the docs, the list if items can be changed. ItemGroup—ArcPy | ArcGIS Desktop. Cannot?
I thought something like the snippet below would do the job, but it doesn't:
sym.renderer.groups.items = new_list_of_sorted_Item_objects
It helps to provide more code. For example, where/how do you get the list of Item objects that you are sorting? How are you sorting the list?
That all said, I was able to crash Pro while tinkering with setting the unique value renderer, so there is a defect because the application should never crash completely. I suggest you open a case with Esri Support.
Thank you for your support. Here is the code I tried to run:
p = arcpy.mp.ArcGISProject('CURRENT') m = p.listMaps('Map1') l = m.listLayers('Lines*') sym = l.symbology sym new_list =  new_list.append(sym.renderer.groups.items) new_list.append(sym.renderer.groups.items) new_list.append(sym.renderer.groups.items) new_list.append(sym.renderer.groups.items) new_listsym.renderer.groups.items sym.renderer.groups.items = new_list
and the screenshot with the error:
Well, most probably in the end I will have to direct to Esri Support, but maybe somebody in the community already came across this issue and found a workaround. Keeping my fingers crossed.