| 899 | } |
| 900 | |
| 901 | func (s Static) compare(o *Static) int { |
| 902 | if s.Type != o.Type { |
| 903 | if s.isNumeric() && o.isNumeric() { |
| 904 | return cmp.Compare(s.Float(), o.Float()) |
| 905 | } |
| 906 | return cmp.Compare(s.Type, o.Type) |
| 907 | } |
| 908 | |
| 909 | switch s.Type { |
| 910 | case TypeString, TypeBooleanArray: |
| 911 | return bytes.Compare(s.valBytes, o.valBytes) |
| 912 | case TypeIntArray: |
| 913 | sa, _ := s.IntArray() |
| 914 | oa, _ := o.IntArray() |
| 915 | return slices.Compare(sa, oa) |
| 916 | case TypeFloatArray: |
| 917 | sa, _ := s.FloatArray() |
| 918 | oa, _ := o.FloatArray() |
| 919 | return slices.Compare(sa, oa) |
| 920 | case TypeStringArray: |
| 921 | return slices.Compare(s.valStrings, o.valStrings) |
| 922 | case TypeNil: |
| 923 | return 0 |
| 924 | default: |
| 925 | return cmp.Compare(int64(s.valScalar), int64(o.valScalar)) |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | // Elements iterate over the elements of a Static value. If the Static is not an array, |
| 930 | // it will loop over itself as the only element |