# Intersect function and order

**URL:** <https://discourse.gohugo.io/t/intersect-function-and-order/31607>\
**Category:** support\
**Created:** [March 6, 2021, 8:23pm UTC](https://discourse.gohugo.io/t/intersect-function-and-order/31607 "2021-03-06T20:23:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swamidass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/swamidass/32/13323_2.png) [@swamidass](https://discourse.gohugo.io/u/swamidass)\
**Post date:** [March 6, 2021, 8:23pm UTC](https://discourse.gohugo.io/t/intersect-function-and-order/31607/1 "2021-03-06T20:23:15Z")

</div>

So, the intersect function takes two lists as input, and outputs a list of the common elements. Does it maintain the order of the elements of one of the input lists? What happens if there is a discrepancy in the ordering?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 6, 2021, 8:33pm UTC](https://discourse.gohugo.io/t/intersect-function-and-order/31607/2 "2021-03-06T20:33:01Z")

</div>

I maintains the order of the first list (e.g. {{ intersect $first $second }}).

---

<div class="post-metadata">

**Author:** ![swamidass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/swamidass/32/13323_2.png) [@swamidass](https://discourse.gohugo.io/u/swamidass)\
**Post date:** [March 6, 2021, 8:36pm UTC](https://discourse.gohugo.io/t/intersect-function-and-order/31607/3 "2021-03-06T20:36:19Z")

</div>

Awesome. That’s what I needed to know.

---

<div class="post-metadata">

**Author:** ![swamidass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/swamidass/32/13323_2.png) [@swamidass](https://discourse.gohugo.io/u/swamidass)\
**Post date:** [March 6, 2021, 8:39pm UTC](https://discourse.gohugo.io/t/intersect-function-and-order/31607/4 "2021-03-06T20:39:13Z")

</div>

See here @bep:

> <https://github.com/gohugoio/hugoDocs/pull/1349>

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [March 8, 2021, 8:40pm UTC](https://discourse.gohugo.io/t/intersect-function-and-order/31607/5 "2021-03-08T20:40:03Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
