Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Package fieldsort defines an ordering of fields. The ordering defined by this package matches the historic behavior of the proto package, placing extensions first and oneofs last. There is no guarantee about stability of the wire encoding, and users should not depend on the order defined in this package as it is subject to change without notice.
package fieldsort

import (
	
)
Less returns true if field a comes before field j in ordered wire marshal output.
func (,  protoreflect.FieldDescriptor) bool {
	 := .IsExtension()
	 := .IsExtension()
	 := .ContainingOneof()
	 := .ContainingOneof()
	switch {
	case  != :
		return 
	case  != nil &&  != nil:
		if  ==  {
			return .Number() < .Number()
		}
		return .Index() < .Index()
	case  != nil && !.IsSynthetic():
		return false
	case  != nil && !.IsSynthetic():
		return true
	default:
		return .Number() < .Number()
	}