# Force ordering in LightXML?

**URL:** https://discourse.julialang.org/t/force-ordering-in-lightxml/46079
**Category:** New to Julia
**Created:** [September 4, 2020, 10:00pm UTC](https://discourse.julialang.org/t/force-ordering-in-lightxml/46079 "2020-09-04T22:00:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 4, 2020, 10:00pm UTC](https://discourse.julialang.org/t/force-ordering-in-lightxml/46079/1 "2020-09-04T22:00:44Z")

</div>

Hello!

Using LightXML my understanding has been that it is in alphabetical order, but for some reason not in this case:

![image](https://global.discourse-cdn.com/julialang/original/3X/0/3/0353419fecbb6d65fba2a59b55252fe068c956e6.png)

And the code is entered as:

```julia
:gravity=>Dict("x"=>0,"y"=>0,"z"=>-9.8065)

```

Would anyone happen to know why / if this can be fixed / forcing ordering?

Kind regards

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 4, 2020, 10:07pm UTC](https://discourse.julialang.org/t/force-ordering-in-lightxml/46079/2 "2020-09-04T22:07:20Z")

</div>

Just as I wrote I found the solution.

Use OrderedDict from [OrderedDicts and OrderedSets · DataStructures.jl](https://juliacollections.github.io/DataStructures.jl/latest/ordered_containers/)

Takes more allocations, but if ordering is important it works very well.

Kind regards

---

<div class="post-metadata">

### Author: ![kimikage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimikage/32/14534_2.png) [@kimikage](https://discourse.julialang.org/u/kimikage)
#### Post date: [September 5, 2020, 11:22am UTC](https://discourse.julialang.org/t/force-ordering-in-lightxml/46079/3 "2020-09-05T11:22:25Z")

</div>

BTW,

> Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.

[https://www.w3.org/TR/REC-xml/#sec-starttags](https://www.w3.org/TR/REC-xml/#sec-starttags)

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 5, 2020, 12:22pm UTC](https://discourse.julialang.org/t/force-ordering-in-lightxml/46079/4 "2020-09-05T12:22:33Z")

</div>

Thanks! I was aware of this, in my case the file is to be used both by human and machine. Therefore it is nice to have it say “x y z” instead of “x z y” etc.

Kind regards
