Skip to content

Commit f61988e

Browse files
committedDec 14, 2011
[BACKPORT] sort layers and fields alphabetically in fTools (fix #4412)
1 parent 7442047 commit f61988e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎python/plugins/fTools/tools/ftools_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from qgis.core import *
3232
from qgis.gui import *
3333

34+
import locale
35+
3436
# From two input attribute maps, create single attribute map
3537
def combineVectorAttributes( atMapA, atMapB ):
3638
attribA = atMapA.values()
@@ -183,7 +185,7 @@ def getLayerNames( vTypes ):
183185
elif layer.type() == QgsMapLayer.RasterLayer:
184186
if "Raster" in vTypes:
185187
layerlist.append( unicode( layer.name() ) )
186-
return layerlist
188+
return sorted( layerlist, cmp=locale.strcoll )
187189

188190
# Return list of names of all fields from input QgsVectorLayer
189191
def getFieldNames( vlayer ):
@@ -192,7 +194,7 @@ def getFieldNames( vlayer ):
192194
for name, field in fieldmap.iteritems():
193195
if not field.name() in fieldlist:
194196
fieldlist.append( unicode( field.name() ) )
195-
return fieldlist
197+
return sorted( fieldlist, cmp=locale.strcoll )
196198

197199
# Return QgsVectorLayer from a layer name ( as string )
198200
def getVectorLayerByName( myName ):

0 commit comments

Comments
 (0)
Please sign in to comment.