# Feature Request: Ordered Arrays

**URL:** <https://discuss.dgraph.io/t/feature-request-ordered-arrays/9644>\
**Category:** Dgraph\
**Tags:** kind:feature\
**Created:** [August 24, 2020, 6:05pm UTC](https://discuss.dgraph.io/t/feature-request-ordered-arrays/9644 "2020-08-24T18:05:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [August 24, 2020, 6:05pm UTC](https://discuss.dgraph.io/t/feature-request-ordered-arrays/9644/1 "2020-08-24T18:05:42Z")

</div>

Continuing the discussion from [Schema for maps of kv pairs with variant values](http://discuss.hypermode.com/t/schema-for-maps-of-kv-pairs-with-variant-values/9569/10):

It would be nice if there was a way to store an ordered set without a messy or concatenating a string to reorder in a UI.

Dgraph supports `[String]` but it is somewhat uncommon knowledge that they work like a set with one gotcha (order)

- Dgraph arrays do not store duplicates
- Dgraph arrays do not store order

This is understandable given the API generated. Removing by value could potentially remove more than one, if they did not work as a set. And adding a value repeatedly could add duplicates when that is not desired.

However sometimes that is the desired structure of arrays. To store duplicates and to store order. How can this be done in Dgraph right now?

Through very messy schema.

Instead of

```auto
type Person {
  ...
  actions: [String]
}

```

In order to handle duplicates and order, it has to become:

```auto
type Person {
  ...
  actions: [Action]
}

type Action {
  id: ID
  order: Int
  action: String
}

```

This then becomes harder to work with now that users have to transform data from a simple array in the UI to arrays of objects with extra parameters.

What is really wanted sometimes is to store this exactly:

```auto
{
  "Person": {
    ...
    "actions":["visited","called","visited"]
  }
}

```

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [August 27, 2020, 5:42pm UTC](https://discuss.dgraph.io/t/feature-request-ordered-arrays/9644/2 "2020-08-27T17:42:10Z")

</div>

For Reference. Acknowledges as GraphQL spec compliance:

> [@GraphQL+- -\> Spec Compliant GraphQL](http://discuss.hypermode.com/t/graphql-spec-compliant-graphql/5891/5):
>
> This has been requested before, but since we’re aiming for spec compliant GraphQL, I thought I’d put this here. Lists in Dgraph behave like an unordered set, which makes perfect sense from a graph point of view, but they do not suit all types of data. The [GraphQL spec](https://spec.graphql.org/draft/#sel-GAFdVFABABbruc) says that “lists are ordered sequences of values”, and I think we should aim for that. In DQL, if we want to use unordered lists for performance benefits, perhaps we could create a directive to guarantee order?
