//
// Copyright (c) 2011-2019 Canonical Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package yaml

import (
	
	
)

type keyList []reflect.Value

func ( keyList) () int      { return len() }
func ( keyList) (,  int) { [], [] = [], [] }
func ( keyList) (,  int) bool {
	 := []
	 := []
	 := .Kind()
	 := .Kind()
	for ( == reflect.Interface ||  == reflect.Ptr) && !.IsNil() {
		 = .Elem()
		 = .Kind()
	}
	for ( == reflect.Interface ||  == reflect.Ptr) && !.IsNil() {
		 = .Elem()
		 = .Kind()
	}
	,  := keyFloat()
	,  := keyFloat()
	if  &&  {
		if  !=  {
			return  < 
		}
		if  !=  {
			return  < 
		}
		return numLess(, )
	}
	if  != reflect.String ||  != reflect.String {
		return  < 
	}
	,  := []rune(.String()), []rune(.String())
	 := false
	for  := 0;  < len() &&  < len(); ++ {
		if [] == [] {
			 = unicode.IsDigit([])
			continue
		}
		 := unicode.IsLetter([])
		 := unicode.IsLetter([])
		if  &&  {
			return [] < []
		}
		if  ||  {
			if  {
				return 
			} else {
				return 
			}
		}
		var ,  int
		var ,  int64
		if [] == '0' || [] == '0' {
			for  :=  - 1;  >= 0 && unicode.IsDigit([]); -- {
				if [] != '0' {
					 = 1
					 = 1
					break
				}
			}
		}
		for  = ;  < len() && unicode.IsDigit([]); ++ {
			 = *10 + int64([]-'0')
		}
		for  = ;  < len() && unicode.IsDigit([]); ++ {
			 = *10 + int64([]-'0')
		}
		if  !=  {
			return  < 
		}
		if  !=  {
			return  < 
		}
		return [] < []
	}
	return len() < len()
}

// keyFloat returns a float value for v if it is a number/bool
// and whether it is a number/bool or not.
func keyFloat( reflect.Value) ( float64,  bool) {
	switch .Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return float64(.Int()), true
	case reflect.Float32, reflect.Float64:
		return .Float(), true
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		return float64(.Uint()), true
	case reflect.Bool:
		if .Bool() {
			return 1, true
		}
		return 0, true
	}
	return 0, false
}

// numLess returns whether a < b.
// a and b must necessarily have the same kind.
func numLess(,  reflect.Value) bool {
	switch .Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return .Int() < .Int()
	case reflect.Float32, reflect.Float64:
		return .Float() < .Float()
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		return .Uint() < .Uint()
	case reflect.Bool:
		return !.Bool() && .Bool()
	}
	panic("not a number")
}