Skip to content

question about rb_sort_clb #2476

@ExclusiveDY

Description

@ExclusiveDY

using version: libyang 3
origin xml: C is list, C-type is key, the type of C-type is enumeration : [XX, 1], [YY, 2]

<A xmlns='urn:ietf:params:xml:ns:yang:A'>
  <B>
	<C>
	  <C-type>XX</C-type>
	</C>
	<C>
	  <C-type>YY</C-type>
	</C>
  </C>
</A>

When I convert this XML into a libyang tree ,I found that the libyang tree became the following.

<A xmlns='urn:ietf:params:xml:ns:yang:A'>
  <B>
	<C>
	  <C-type>YY</C-type>
	</C>
	<C>
	  <C-type>XX</C-type>
	</C>
  </C>
</A>

I found that the reason for this behavior is that the lyplg_type_sort_enum function sorts the enumeration types from largest to smallest, while for the string type, its sorting function lyplg_type_compare_simple sorts from smallest to largest. For the boolean and decimal64 types, the sorting is also from smallest to largest.
Question:
1、I would like to know what considerations led to this difference?
2、I expect the libyang tree to maintain the original XML order. how should I do this?

Looking forward to your reply. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:questionIssue is actually a question.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions