func sortExprLabels(e bzl.Expr, _ []bzl.Expr) {
	list, ok := e.(*bzl.ListExpr)
	if !ok || len(list.List) == 0 {
		return
	}

	keys := make([]stringSortKey, len(list.List))
	for i, elem := range list.List {
		s, ok := elem.(*bzl.StringExpr)
		if !ok {
			return // don't sort lists unless all elements are strings
		}
		keys[i] = makeSortKey(i, s)
	}

	before := keys[0].x.Comment().Before
	keys[0].x.Comment().Before = nil
	sort.Sort(byStringExpr(keys))
	keys[0].x.Comment().Before = append(before, keys[0].x.Comment().Before...)
	for i, k := range keys {
		list.List[i] = k.x
	}
}
func sortExprLabels(e bzl.Expr, _ []bzl.Expr) {
	list, ok := e.(*bzl.ListExpr)
	if !ok || len(list.List) == 0 {
		return
	}

	keys := make([]stringSortKey, len(list.List))
	for i, elem := range list.List {
		s, ok := elem.(*bzl.StringExpr)
		if !ok {
			return 
		}
		keys[i] = makeSortKey(i, s)
	}

	before := keys[0].x.Comment().Before
	keys[0].x.Comment().Before = nil
	sort.Sort(byStringExpr(keys))
	keys[0].x.Comment().Before = append(before, keys[0].x.Comment().Before...)
	for i, k := range keys {
		list.List[i] = k.x
	}
}
func sortExprLabels ( e bzl . Expr , _ [ ] bzl . Expr ) { list , ok := e . ( * bzl . ListExpr ) if ! ok || len ( list . List ) == 0 { return } keys := make ( [ ] stringSortKey , len ( list . List ) ) for i , elem := range list . List { s , ok := elem . ( * bzl . StringExpr ) if ! ok { return // don't sort lists unless all elements are strings } keys [ i ] = makeSortKey ( i , s ) } before := keys [ 0 ] . x . Comment ( ) . Before keys [ 0 ] . x . Comment ( ) . Before = nil sort . Sort ( byStringExpr ( keys ) ) keys [ 0 ] . x . Comment ( ) . Before = append ( before , keys [ 0 ] . x . Comment ( ) . Before ... ) for i , k := range keys { list . List [ i ] = k . x } }
// sortExprLabels sorts lists of strings using the same order as buildifier.
// Buildifier also sorts string lists, but not those involved with "select"
// expressions. This function is intended to be used with bzl.Walk.
sortExprLabels sorts lists of strings using the same order as buildifier . Buildifier also sorts string lists but not those involved with select expressions . This function is intended to be used with bzl . Walk .