[Question]
  [
Consider the array `[5, 6, 8, 3, 9, 4, 2, 1, 7]`. If we list how far each number has moved from it's (1-indexed\*) index, we have (considering absolute distance):
```
Array: [5, 6, 8, 3, 9, 4, 2, 1, 7]
Index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Dists:  4  4  5  1  4  2  5  7  2
```
We can then group the elements of the array based on their distance away from their indices:
```
[[3], [4, 7], [5, 6, 9], [8, 2], [1]]
```
Additionally, we can optionally include empty lists to indicate distances not there (e.g. `0`):
```
[[], [3], [4, 7], [], [5, 6, 9], [8, 2], [], [1], []]
```
Note that the maximum distance an element can be from its index is `len(list) - 1` and the minimum is `0`, so the list (including empty lists) will always be the same length or less as the original list.
\*: Note that it doesn't matter if we use 1 or 0 indexing
---
Given a list of `n` positive integers, group the elements of the list by their absolute distance from their indices. The input is guaranteed to be a permutation of `[1, 2, 3, ..., n]` and will have a minimum of `3` elements. You may choose to include empty lists in the output, but only if the length of the output is the same length as the input.
The elements of the groups can be separated with any clear, consistent, non-digit separator, and the groups themselves should be separated in the same way, but with a separator that's different from that used to separate the elements of the groups. For example, spaces and newlines, or nested lists.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the shortest code in bytes wins.
## Test cases
```
[1, 3, 2] -> [[1], [3, 2]]
[3, 2, 4, 1] -> [[2], [4], [3], [1]]
[1, 2, 3, 4] -> [[1, 2, 3, 4]]
[2, 5, 3, 1, 4, 6] -> [[3, 6], [2, 4], [5, 1]]
[2, 1, 3, 6, 5, 7, 4] -> [[3, 5], [2, 1, 7], [6], [4]]
[1, 7, 4, 2, 8, 6, 3, 5] -> [[1, 6], [4], [2], [8, 5], [3], [7]]
[2, 6, 8, 3, 1, 7, 9, 5, 4] -> [[2, 3, 7], [9], [5], [6, 1], [8, 4]]
[5, 6, 8, 3, 9, 4, 2, 1, 7] -> [[3], [4, 7], [5, 6, 9], [8, 2], [1]]
[1, 7, 5, 10, 8, 9, 6, 3, 4, 2] -> [[1], [6], [5], [8, 9], [7, 3, 4], [10], [2]]
[10, 8, 5, 9, 2, 3, 4, 7, 6, 1, 11, 12] -> [[11, 12], [7], [5], [2, 3, 4, 6], [9], [8], [10, 1]]
[3, 5, 10, 11, 6, 7, 12, 14, 8, 2, 9, 13, 1, 4] -> [[6, 7, 8, 13], [3, 9], [5], [12], [14], [10, 11], [2], [4], [1]]
[6, 14, 8, 9, 12, 4, 13, 7, 5, 15, 10, 11, 3, 1, 2] -> [[7, 10, 11], [4], [5], [6, 8, 9, 15], [13], [12], [3], [14], [1, 2]]
[8, 12, 13, 7, 16, 5, 14, 15, 3, 10, 2, 4, 1, 9, 11, 6] -> [[10], [5], [7], [11], [9], [3], [8, 14, 15], [4], [2], [12, 13, 6], [16], [1]]
[14, 5, 10, 1, 2, 4, 13, 9, 7, 12, 8, 11, 3, 15, 16, 6] -> [[9, 11, 15, 16], [4, 7, 12], [5, 1, 2, 8], [13], [10], [3, 6], [14]]
[19, 8, 16, 15, 2, 6, 11, 18, 12, 9, 3, 14, 4, 1, 7, 5, 17, 13, 10] -> [[6, 17], [9], [14], [2, 12], [11], [13], [8], [3, 7], [4, 10], [18], [15, 5], [16, 1], [19]]
[19, 11, 7, 5, 3, 1, 20, 16, 17, 15, 10, 13, 6, 18, 2, 12, 9, 4, 14, 8] -> [[5, 10, 13], [3], [7, 18, 12], [1, 15, 14], [6], [16, 17, 9], [11], [8], [20, 2], [4], [19]]
```
  
[Answer]
# [J](http://jsoftware.com/), 10 bytes
```
</.~]|@-#\
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/bfT16mJrHHSVY/5rcqUmZ@QrpCmY6iiY6ShY6CgY6yhY6iiY6CgY6SgY6iiYwxQYKhgrGME4QKaCiYIhjAtUagrWaQjWafYfAA "J ‚Äì Try It Online")
* `</.~` Group by...
* `]|@-#\` Absolute value of `|@` input minus all length prefixes (ie, 1 2 3... n)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
·∫°Jƒ†·ªã
```
A monadic Link that accepts the list of integers and yields a list of lists of integers.
Does not perform the optional empty list insertions.
**[Try it online!](https://tio.run/##y0rNyan8///hroVeRxY83N39////aFMdBTMdBQsdBWMdBUsdBRMdBSMdBUMdBfNYAA "Jelly ‚Äì Try It Online")**
### How?
Pretty simple for Jelly this one...
```
·∫°Jƒ†·ªã - Link: list of integers, A
 J   - range of length of A -> [1,2,...,length(A)]
·∫°    - A absolute difference that (vectorises)
  ƒ†  - group indices of that by their values
   ·ªã - use those to index back into A
```
[Answer]
# JavaScript, 151
```
x=>x.map((y,i)=>[y,Math.abs(y-i-1)]).sort((a,b)=>a[1]-b[1]).reduce((g,z)=>d-z[1]?(d=z[1],[...g,[z[0]]]):[...g.slice(0,-1),[...g.at(-1),z[0]]],[[]],d=0)
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 11 bytes
```
≈º-»ßZ‚ÅΩt·π°fyƒ†‚Ä¢
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLFvC3Ip1rigb104bmhZnnEoOKAoiIsIiIsIls1LCA2LCA4LCAzLCA5LCA0LCAyLCAxLCA3XSJd)
The pains of not having tons of array focused built-ins
## Explained
```
≈º-»ßZ‚ÅΩt·π°fyƒ†‚Ä¢
≈º           # The range [1, len(input)]
 -»ß         # and the absolute difference with the input
   Z        # Zip those together
    ‚ÅΩt·π°     # and sort that by tail - this is a work around way to group one list by the results of a function applied to it
       fy   # flatten and uninterleave this - this pushes the original list and the absolute differences but sorted
         ƒ†  # group the indexes on consecutive items
          ‚Ä¢ # and mold the other list to the shape of that.
```
[Answer]
# [Factor](https://factorcode.org/), 52 bytes
```
[ dup '[ dup _ index 1 + - abs ] collect-by values ]
```
The `collect-by` word postdates build 1525, the one TIO uses, so here's a screenshot of running the above code in build 2101's listener:
[![enter image description here](https://i.stack.imgur.com/JlFLe.png)](https://i.stack.imgur.com/JlFLe.png)
`collect-by` is a combinator that collects values in an associative array by a given quotation. The quotation calculates the difference between an element and its index. Then we take only the values from the associative array, discarding the keys.
[Answer]
# [R](https://www.r-project.org/), 32 bytes
```
function(x)split(x,(x-seq(x))^2)
```
[Try it online!](https://tio.run/##jZTdbtswDIXv9xQGdmMDLmA6sn4u2hcJsmLLsiFAl3ZtCmRPn4k81I@xTdlFmlQSeT4eUnq9fn99fn95/PLr8evx7eXp8/7w43A631@/vZ/25@Pzqb8Mcfl47i9jf7l7O/yMC8Onefh7XL/vaew2YzcPQ/exu3votlvajd2Wl3a7D/8K4u2xM2NHJW7mOCPB/Ica4SThMYmpZPNaIzCeWOQQibot4XHNsixj8Xc8Ru1EKNxKRrdCicuL5oqHHP@0KK5ZkhOmGOQlLWdZlWezQWKVVxVxy7VZrSRF3VEmCHRFDOeENEj1wswWQKhFvlTpQyqBdSpDhFwFcD5o5vk/eu0ElyZRCckc8@fU2czuVcHpSLDIBOsaUlBYRGROIk4EIwbxp5aU/@F@0s1RNnvpId6ep00ukbNaUSX20QjSLEikg1sQcNDzlt660j6gkcnylEfH3DLdZuUADgN17USFCqTKFZf2slAaJs0GuE1B3FSc7WfDqykgIdw9BiW91VN@V6BFqzuOCVhyx8AYMoNPydYXLUlKS8neHFhTeplxcDe0qb5Yt6CMClKxsZPuTRq0JeX0lYmTtt6qjw20AHGL/HgYRE2dDaAyyUPtt9PZm1aTR@W9QPfmhAljgeeVzmktwCUUsOgbRumtoXADnzKVTt6k9bhqLvEuEy6O1mV0pEsJ@XR5RZMTOouS0OSXJemEUqOUwQzVveISrr8B "R ‚Äì Try It Online")
([51 bytes](https://tio.run/##K/qfXpRfWhCfVBmfkllckJOYnJqbmldi@z@tNC@5JDM/T6NC0zexQAPOzdOsiE5MKtao0C3WtLXNi9UpttEtTi0EKtPEbpRGsoapjoKZjoKFjoKxjoKljoKJjoKRjoKhjoI5UA8A) if we want to include the empty lists for displacements that don't occur:  
`function(x)Map(function(n)x[abs(x-s)==n],s<-seq(x))`, painfully long because of the double "`function`" keyword, although this could be replaced by "`\`" in [R](https://www.r-project.org/)‚â•4.1 for 37 bytes)
[Answer]
# [Python 2](https://docs.python.org/2/), 111 bytes
```
o={}
for a,b in[[abs(x+1-y),y]for x,y in enumerate(input())]:o.setdefault(a,[]).append(b)
print[o[p]for p in o]
```
[Try it online!](https://tio.run/##JY5BDoIwEEX3PcXsaHUkAoJiwkmaLgqMkUTbBkpCYzw7Qt1N/sv7f1zwT2vytbM9QQNJkqy2@XzZw46gsYXBSKnbiS/H7BQEBrWDBcMGgMz8plF74oNxs@dCqLtNJ/I9PfT88lyjVCLVzpHpeSuYGwfjpZUutri9w6p122S0UMf3HwQcoFhliVAh3BAKhBrhgpAjZAhXxeR2lRFkEVRbtJOYZudo1VEv/qL6AQ "Python 2 ‚Äì Try It Online")
Not particularly short or clever but it was fun. Unbelievably `o.setdefault(a,[]).append(b)` is shorter than any way I could find of using a comparison.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
.¬°NŒ±
```
Input and index-comparison are both 0-based.
[Try it online](https://tio.run/##yy9OTMpM/f9f79BCv3Mb//@PNtFRMNVRMNdRMNJRsNBRMNZRMNRRMNBRMIsFAA) or [verify all test cases](https://tio.run/##NVCxDcJADFwlSm2hd/4/@VRswAJRCpAoqCiQkFLQMgAbMAIrMABDsEi4sx8pUuzz3fn858v@cDqu12XbNt/7o2m3y7p5P3ef13qTdZqCdKKzNBN@EiWwDCg7iSxVEsqASfaW/Ayw93lgAfoAsJPknIyWol4KmMZLFSzGxugvTjJiUEwePQmBBMhCgJLBV3w1JhVoMyaqohFsJdtikpIdLBxH4tyiVUaWGQ2m5lB5DyTKU0d/BqpDvTnayiDVrfjiwd0ggt6JhWA2CPEY2ZYU0qK5WpKeLmNVqIMWazR1X7PynWngFtGOmucf).
The groups are sorted based on their first occurrence, rather than their index-difference, which is allowed in the comments. If this wouldn't have been the case, it would be this 14 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) monstrosity instead (with 1-based input/comparison), since 05AB1E lacks a sort + group-by builtin in one, and doing them one at a time when comparing it to their index isn't exactly ideal..
```
ƒÅ√∏Œ£√Ü√Ñ}.¬°√Ü√Ñ}‚Ç¨‚Ç¨–Ω
```
[Try it online](https://tio.run/##yy9OTMpM/f//SOPhHecWH2473FKrd2ghmH7UtAaILuz9/z/aVEfBTEfBQkfBWEfBUkfBREfBSEfBUEfBPBYA) or [verify all test cases](https://tio.run/##NVA7TsQwEL1KtPUIZTa2E1d7kCgFSBRUFEhIW1CA0B6AG6xoOQANDaFGnGEvEt57k0iWPPM@4ze@f7i@ubtdHo@HXXM5vTW7w3H5eZ4/f9/n0/z6dPV91n15@cD5@1psGUe3zvaTNSMuS@YsHWVnieXeMkoHU6KlvgDsg3cWkA8AO8uhKWhp6q1CKV1ewSo1qM2czVswVf4UUYRkYIoBUYHDcdag8qAvoBzTEuR7yF1JqSkBVtKJuB7afJRp1CA7WedO8LjWbeMv6PdYHFS4bR1Y4@1hnZc5IZSVYCHEn2BsPVMpSxqrML3itqvFA1WyVvZ@y8v/di6oIUmbTdM/).
**Explanation:**
```
.¬°       # Group the (implicit) input-list by:
  N      #  Push the 0-based index
   Œ±     #  Get the absolute difference of this index and the number
         # (after which the list of lists is output implicitly as result)
ƒÅ        # Push a list in the range [1,input-length]
 √∏       # Create pairs with the input-list
  Œ£      # Sort this list of pairs by:
   √Ü     #  Reduce the pair by subtracting
    √Ñ    #  And take the absolute value of that
  }.¬°√Ü√Ñ  # After the sort-by, do the same with a group-by
    }‚Ç¨   # After the group-by, map over each list of pairs:
      ‚Ç¨  #  Map over each inner pair:
       –Ω #   Only leave the first value
         # (after which the list of lists is output implicitly as result)
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 28 bytes
```
GatherBy[#,i=0;Abs[#-++i]&]&
```
[Try it online!](https://tio.run/##XZRda9swFIbv/SuMO8pGFbAcWbYIKdlYGYNejGV3whdZcDdD6wRbhY7S357pfEjydpFEts553@ccHeXp4H73Twc3HA@Xh@3lCzxOn/7YKzFsy83Hn7O9Wt3cDN11d31x/ezmfJvv3TSMv@5e3HQ4Ovtuf5yGs/s6np8d7YgiK1a3m40o8tVtjssu@3yy2eswitOze/MaP053L@epn@fhNO4o7Xt/fjwce1tYn1LcD7OzRbd7HMZ@k33zAc4O4@r2YedFivx9Ifanye3gcbvFpVcWxYeiy8QrJAnEfesuVop8LfKqAxprZSdyi89dhr8iVyKXvFvBrsIQ@JIQJDHIh6ogkV74bb@s8UmikuagNSy9BOjDbw0mFE5AGvOaJOvf1ZzhIxpYasIhiAb1/W6LyRgegXQExxJa1sIqGvbVmEqkXswgQHCnitDVIC/6AzTJIUW9EDEBB2G5BKRgGQo2nF8t@9mgtSxRy4Ry1H@npCNHyzoNtx2kSioWBEmnRqkqSDUo680kfKIwPWBXgnpM0bH6liz4zNYRF9I1akuoXKFxhcaSR4CNKKqF9zxxqa0EIFU0kfHgVGyTjvqG3BR5cO8WQGQcKmzCRpQLR8lShLBOIOsFDV@MlgskP0mzCjiSZ72MN4dEZZp8Opk69phITHRqg9K/Ixv88BCkTuOiUvejKc0fH0Ob2lATbEBhMnodZjMMQB0E20VDSj4szT0BAEMWmoToIqEsd8mQtwr94BNqeCbKNBEy3S/qdxVgqEkE0TJDw8QEJQmz5pstw92UJkDK6M0TUTJ1s5gX@ueRNLZMr3jUGDSGpn@QUCzPCKqpeEeDiUmVICwALKbag/4F "Wolfram Language (Mathematica) ‚Äì Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-Q`](https://codegolf.meta.stackexchange.com/a/14339/), 4 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
√º√àaY
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVE&header=bV8tMQ&code=/MhhWQ&input=WzUsIDYsIDgsIDMsIDksIDQsIDIsIDEsIDdd)
* saved 1 by 0-indexing
```
√º      - sort and group by:
 √à     - f(value,index)
  aY   - distance(value,index) 
```
[Answer]
# [BQN](https://mlochbaum.github.io/BQN/), ~~13~~ 11 bytes[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)
Saved 2 bytes thanks to Razetime
```
{ùï©‚äîÀú|ùï©-‚Üï‚â†ùï©}
```
[Run online!](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAge/CdlaniipTLnHzwnZWpLeKGleKJoPCdlal9CgpGIDXigL824oC/OOKAvzPigL854oC/NOKAvzLigL8x4oC/Nw==)
Outputs with empty lists (the first group is at the back though)
The best train I could get was `‚ä¢‚äîÀú(|‚ä¢-‚Üï‚àò‚â†)` (also ~~13~~ 11 bytes). Razetime found two even smaller trains: [`‚ä¢‚äîÀú¬∑|‚äíÀú‚ä∏-`](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAg4oqi4oqUy5zCt3ziipLLnOKKuC0KCkYgNeKAvzbigL844oC/M+KAvznigL804oC/MuKAvzHigL83) and [`(|‚äíÀú‚ä∏-)‚ä∏‚äî`](https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgKHziipLLnOKKuC0p4oq44oqUCgpGIDXigL824oC/OOKAvzPigL854oC/NOKAvzLigL8x4oC/Nw==), both 9 bytes!
```
{ùï©‚äîÀú|ùï©-‚Üï‚â†ùï©}
  ‚äîÀú        # Group the elements of
 ùï©          # the input by
    |ùï©-‚Üï‚â†ùï©  # the displacements
       ‚Üï‚â†ùï©  # Indices of the input: range (‚Üï) to length (‚â†)
     ùï©-     # Distance from each element to its corresponding index
    |       # Absolute value
```
[Answer]
# JavaScript (ES6), 48 bytes
The output includes empty lists.
```
a=>a.map((_,i)=>a.filter((v,j)=>(v+=~j)*v==i*i))
```
[Try it online!](https://tio.run/##dZFBboMwEEX3PYWXduomMgETFs5FkFVZKVQgGqIkYpmrU8@3S2khLADbM4/3h9YN7na6Npf727n/qMbajM4c3fbLXTh/l42gRd109@rK@SBbv@bDq3m0YjMY02waIcZTf771XbXt@k9e81JJtpcssWxxCcF2O1aWykpWosa@/GumXclSyZR90pxQcwoC3dSSocDwpPQZY1ax6PYHGc4UPLRddO9p13@aROmZke0aJ0xCA5j/6sw4WeT4ypxedQi3FimHjq89AInmv5H0NBnM6BDxGFO@KqhBC1k9v4BpaqdR4wxiBYJCkdIG/IpoNoMWP8ZIN6WGZcSG8iLykvhDx28 "JavaScript (Node.js) ‚Äì Try It Online")
[Answer]
# [Python 3](https://python.org/) + [pandas](https://pandas.pydata.org/), 48 bytes
```
lambda s:s.groupby(abs(s-s.index-1)).apply(list)
```
Input `pd.Series[int]`, output `pd.Series[List[int]]`. Could be 46 bytes if we use 0-indexed.
TIO didn't have pandas installed (although it installed NumPy). So no TIO link available.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 42 bytes
```
->a{r=0;a.group_by{|x|(x-r+=1)**8}.values}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6xusjWwDpRL70ov7QgPqmyuqaiRqNCt0jb1lBTS8uiVq8sMac0tbj2f4FCWnS0oY6xjlFs7H8A "Ruby ‚Äì Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 5 bytes
```
kS‚â†‚Ç¨¬π
```
[Try it online!](https://tio.run/##yygtzv7/Pzv4UeeCR01rDu38//9/tKmOmY6FjrGOpY6JjpGOoY55LAA "Husk ‚Äì Try It Online")
```
k           # group each x in input by
 S‚â†         # difference between x and          
   ‚Ç¨        # index of x in
    ¬π       # input
```
[Answer]
# [Haskell](https://www.haskell.org/), 83 bytes
```
g a=(\l->map(\k->[fst m|m<-zip a$map(\n->abs$1+n-a!!n)l,snd m==k])l)[0..length a-1]
```
[Try it online!](https://tio.run/##HchNDoIwEAbQq3wkLCBOifUHNbG9SOlijAgN7YRYVsa718S3fDPnZYyxlAlsmiEqm3hthkVZ98ob0jfd1Ses4Pr/oiw/cq13oriqpI2U5YlkzOLb2Lp918VRpm0GK@1L4iBmfQfZ6smdCT3hSjgSboQT4UDQhIsvPw "Haskell ‚Äì Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~91~~ ~~86~~ 84 bytes
```
j;i;f(a,n)int*a;{for(i=n*n;i--;j||puts(""))abs(a[j=i%n]-j)-i/n||printf("%d ",a[j]);}
```
[Try it online!](https://tio.run/##XZLtboMgFIb/9ypOSJqAPaTzY5/M7UI6szitDWajS3HZstZbn0OwVeQHyHneF17Agu@KoutqIUVFc1RMqibIxbHaH6hMVaCE5FzUp9PnV6MpIYzlb5rmmzqVS5XxmnG5VoYejK@iZFkCQUMzJtrOlOAjl4oyOC7AtL7QbHUTbjJI4XiNcINwhxAj3CMkCBFCiHDbCk8eOXlohdEMxg7G1myWCGc8uZgj609GHliBdgKbC91@bojdkMwWfFXOoOXvdl9R62PrYRa4KcKERj6NfBr7NPZp4tOEDWHM8wDtE0lVbn9MnCsxfD5O7dq3ayZgtbK685OMV2EWcddheSamGNRAzeHneIwyxDARlN1nukffmo3MeBoKr3j5c/SyJAjy2XTkgZi@l7NR3C7mFuBPL4pMJObQCGpSOCvTeRt97aLt/orqPd/pjn//Aw "C (gcc) ‚Äì Try It Online")
*Saved 5 bytes thanks to [tsh](https://codegolf.stackexchange.com/users/44718/tsh)!!!*  
*Saved 2 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!*
Inputs a pointer to an array of integers and its length (because pointers in C carry no length info).  
Outputs the \$0\$-indexed numbers (separated by spaces) in displacements groups on separate lines for each possible displacement (so there may be empty lines).
[Answer]
# [Haskell](https://www.haskell.org/), 50 bytes
```
(\a->[[y|(j,y)<-a,abs(j-y)==i]|(i,_)<-a]).zip[0..]
```
[Try it online!](https://tio.run/##FchLDsIgFAXQrdyBA4gPYv2biBuhxDwbUSptiDjBdO2iDs7k3Dk/rjFWb9oqWlYna8skeiryqJj4kkWvijQmuEkEOv/XSf0OyS60dnXgMMIgPcP4wgz@Z@AEoZq5hN0QtoQ9YUU4ENaEJaEh7Fz9dD7yLVfVpfQF "Haskell ‚Äì Try It Online") Uses 0-indexing
[Answer]
# [Python 2](https://docs.python.org/2/), 70 bytes
```
l=input()
d=[[]for _ in l]
n=1
for x in l:d[abs(x-n)]+=x,;n+=1
print d
```
[Try it online!](https://tio.run/##HclBCoMwFAXAfU7xlorPhbZVq@QkIZSWUAzIN9gI8fRp7XKYcMR5lTbnRXsJeyxK5bQx9r1ueMALFqtEN@p0@nt05vn6FKmW0lY6cZLq92HzEuFyNjeiIwbiQtyJK9ESDdHbLw "Python 2 ‚Äì Try It Online")
Full program. Output includes empty lists.
-11 thanks to @loopywalt
[Answer]
# [Haskell](https://www.haskell.org/), 43 bytes
```
f x=[[b|(a,b)<-zip[0..]x,abs(a-b)==y]|y<-x]
```
[Try it online!](https://tio.run/##BcFLCoAgFAXQrTRoYHCN/jXQlYiDJyRJJlENNNq7nbPRva/e52yLKJUyHyOYSvDXnaqpax1B5mbETSVl0l8SPOp8kAvyvFx4SqsWzJgwYkCPDi0anX8 "Haskell ‚Äì Try It Online")
*Zero indexing. Outputs with empty lists*.
Nothing really clever here. I'm quite surprised that this is the shortest of *3* Haskell answers.
## Explanation
We have a first list comprehension
```
f x=[...|y<-x]
```
From `x` it takes all the possible distances we are looking for. Since `x` is a permutation every number we want appears and it appears exactly once.
Inside we have a second comprehension.
```
f x=[[...|(a,b)<-zip[0..]x,...]|y<-x]
```
Here we take an index and a value from `x`. Using `zip` to get the indexes.
```
f x=[[...|(a,b)<-zip[0..]x,abs(a-b)==y]|y<-x]
```
We filter only the ones such that their absolute difference is the desired distance.
```
f x=[[b|(a,b)<-zip[0..]x,abs(a-b)==y]|y<-x]
```
Then we return the value.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 11 bytes
```
Ôº©Ôº•Œ∏Œ¶Œ∏‚ÅºŒ∫‚Üî‚ÅªŒªŒº
```
[Try it online!](https://tio.run/##JYvLCsJADEV/JcsIERxfVVxJ0V3BfeliLAUHYx/z8PfHOxhy4OaE27@s7yerOT@8GyPXNkRu7MyL0N1pHHxJtyVZDfwWuj7DpCkO3LgxBVahz@o/l5zb1pyEzEboKLQX2gohmzM4AEgDW058iqkAFqC3QwJV1@X1V38 "Charcoal ‚Äì Try It Online") Link is to verbose version of code. 0-indexed. Output includes empty lists. Lists are double-spaced from each other. Explanation:
```
  Œ∏         Input array
 Ôº•          Map over elements
    Œ∏       Input array
   Œ¶        Filtered where
         Œª  Inner value
          Œº Inner index
       ‚Üî‚Åª   Absolute difference
     ‚Åº      Equal to
      Œ∫     Outer index
Ôº©           Cast to string
            Implicitly print
```
[Answer]
# Python3, 96 bytes:
```
f=lambda x,i=1,d={}:f(x[1:],i+1,{**d,(j:=abs(x[0]-i)):d.get(j,[])+[x[0]]})if x else[*d.values()]
```
[Try it online!](https://tio.run/##XVTbbuIwEH3efoUfE@qtMonjSyS@JMpDELCbilIEbEVV9dvZeC526APIl5lzzswc5/R5/ft@bPzpfL/v14fxbbMd1U1Pa9Db9dd3ty9uPXSDnp5Bf61WW128dutxc5mPq@H3VJbd9uXP7lq86n4on/t4OnyX017d1O5w2fWr7cvHePi3uxTlcN@/n9Wo1UZNR9X3PWjVaFUPet5A/MfdgPu41MpohRc9BhmMiX/AUYBRc6z5uaX7edfiASCWFWhc1JzWRpIUT6IsJjoBnk9aTpnvXVxaUpR0OGSYAzxmS0a8skk8luH5CitxmdliLomd0QJKMHLbMG9AyaiAm@Nzve0CJYggUUyEhncUGhig/tFVh@RQIViQiszDtGxS4hnI5VlARfUyIgG1iFULlkPcmQ3ij5HT0iX4lGBTAzxx5Mk1SXBEsAgOsXiDzDUyAzsBMyjGx1P2Xm4tKQCTWCBNzyw7ZRNBIDpDJNy@hSJiphqdHCc8mScDkYYmK2kWcvIb8VwiEQJ5NuoBNn2VHhHhihd5Om1qM0kJicoLzqNzhQ1BwD54xuQBJFZyIU/C50a0pJa0sDA6FIeKCVqB84uWVDwvy11hBYE4LGHRg0Jk7lMgciMd4SE59kWVJprfGbW8FjXUJlLhWYRjyZQPpLPlJw7yRiEsVEIiZ1dULNstPEMfISDvsnzDdpO3ToH5WyK1sk8Qy6SnKhQhl4JIkX5h7ah06J5@nc7T8Vrsi7Esn@7/AQ)
[Answer]
# Scala 3, 64 bytes
```
l=>l.indices.map(d=>l.indices.filter(i=>(i+1-l(i)).abs==d)map l)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=hZXBjpswEIZvPeQpLJoDqCTCxBioRLSXHir11iOJKppAi8SSFNiqUtUn6SWX9in6IrtP0_HM2NC99JAA9vj_P4_H9s_f46nqqt3t8eXXqhPNa_GuHafybT8dRbEX7-svpfmZb2j49TA1m-zxriv23bbtz-2pHrf31dU_LxuatpvqwW-Lvd--kpvOb4NgW30ci-IcQLDoAtJ5evHHeJ6qsR5FITzPK2UodqGIj2KzF2Upj6Eo8fu4wmcoVCgk98amV2GI-ZMmSGIQhCorMTdAN7wm-CVRSXPQzryChNE3z8SYUDgBaRyXzrLQlvAIiEjNqyYcgkhRH3ozHIzhDkg7cJxCxlo4i5R9NQ4lUhDLEcC604zQNUde9DfQJIcUyUIktzgIy1NACpah4JzHx8t8pmgtI9TK7XTUs1XSjiNjnZTTbqQimqwRJJ0EpWIrlaIsmEnzc8L0gVmx6m6IdrPPyILXbOdwzXCN2tLMXKFxjMaSS4CNKCoz7Vxxc1oJQCpnIt3CKZcm7fRzclPkwblbAJGxnWFqO5ycXUqWIoTdDLJb0PDGyHiC5CepVg2O5FqP3M4hUTlXPq1M4nJMJLlzyqzSvyVr_XARpJ7LRc3Zd6ZUf7wM2ZyGhGAtCpNRs61NWwCJFcwWCYl4sTTnxADkZKFJiDYSynKWcvJWNh-8QinXRDRXhJz3F-U7tjCUJILImCFlYoKShJnwzpZ2b8rcQkrnzRURMXW6qBc6eSSVLdMrLjUGdaHzCWInyzWCasrtUWuSzzNBWAOwqGoAhfN4tbq7r9penOtG4EuxEnReb8dr106-d-i9YNtchro6fRbfoZf6xeiV67ZnyPXlAa4PDy4UDBDCHPvVMMCh3_ZWKRSgNF3M9YNXygf4gGsnWAwZ8J4AMed-ANjDoXw-8j-SS81Plwk0Gx9wbPN1aPup6_3Re_PtWp-m-izWYB1i7Br-PBP5gy6x242efwE)
Includes empty lists.
[Answer]
# Haskell + [hgl](https://gitlab.com/WheatWizard/haskell-golfing-library), 18 bytes
```
cr<<<bgB(Uc aD)<eu
```
*0 indexed*
# Haskell + [hgl](https://gitlab.com/WheatWizard/haskell-golfing-library), 21 bytes
```
cr<<<bgB(Uc aD)<zp nN
```
*1 indexed*
## Explanation
The main crux of this is `bgB` which groups a list into chunks using a conversion function. This function was inspired by [this answer](https://codegolf.stackexchange.com/a/240388/56656).
The first thing we do in each answer is pair every element with it's index. For zero indexed that's `eu`, but for one indexed it's a little more expensive `zp nN`.
Then we do the grouping. We use `bgB` and our conversion function is the absolute difference `aD`. Since we need to operate on a tuple we have to uncurry `aD` with `Uc`.
Once we've made the groups we need to go remove the indexes, `cr` gets the second element of a tuple so we triple map `cr` to get the second element of every tuple.
## Reflection
This feels very big for what it's doing. It's nice we have the `bgB` to work with, but it doesn't quite fit here. The issue is that `bgB` is a very local function but index is a non-local property. So we need to put the indexes in, and then take them out. Not to mention this adds the currying necessary.
It's possible to imagine a version of `bgB` that doesn't have this issue, but it seems like it would be very specific to this problem.
[Answer]
# [APL(Dyalog Unicode)](https://dyalog.com), 24 bytes [SBCS](https://github.com/abrudz/SBCS)
```
{‚çµ‚àò{‚ç∫[‚ç∏‚çµ=1+|‚ç∫-‚ç≥‚â¢‚ç∫]}¬®‚ç≥‚â¢‚çµ}
```
Outputs with empty lists.
[Try it on APLgolf!](https://razetime.github.io/APLgolf/?h=AwA&c=q37Uu/VRx4zqR727oh/17gDybA21a4A83Ue9mx91LgKyYmsPrYBxttYCAA&f=NVDtEcUgCPv/pmAEU5GWhbr/CC@J9q5nMR8QfAMx4/q9OiMDrMBqRrK6YrEC8fJN2iJ2m4X@RB9iM5YVxds009RJtQ7W1pI5zhUYJNrmdAQDi5DnU1NUgt/OZwevRQZslVRfVMMRKamNtdgU7CmfTSo1emwWCe1CC7zl2A8gO7wvme2N06734Od0W2pgYQsrIXoBJfaQlird1EluRx3bgQ061bD7/rLqkaHd3CO91R8&i=AwA&r=tryapl&l=apl-dyalog&m=dfn&n=f)
Idk how to convert this to tacit lol, I'm sure it's possible though.
```
{‚çµ‚àò{‚ç∫[‚ç∏‚çµ=1+|‚ç∫-‚ç≥‚â¢‚ç∫]}¬®‚ç≥‚â¢‚çµ}
{                      }             ‚çù  a dfn in which...
                   ¬®                 ‚çù  for each element in...
                    ‚ç≥‚â¢‚çµ              ‚çù  the range 1 to the length of the input...
 ‚çµ‚àò{‚ç∫[‚ç∏‚çµ=1+|‚ç∫-‚ç≥‚â¢‚ç∫]}                  ‚çù  apply the following function, 
                                         with original the input passed in as the left argument:
   {     1+|‚ç∫-‚ç≥‚â¢‚ç∫ }                  ‚çù  calculate the distance between the original list
                                         and its indices + 1...
      ‚ç∏‚çµ=                            ‚çù  and keep the ones that are equal to the right argument
                                         (which is an element from the range we are looping over)
    ‚ç∫[           ]                   ‚çù  then index the input (left argument)
                                         with the filtered list of indices
```
[Answer]
# Python/NumPy, 47 bytes (@tsh)
```
lambda a:[[*a[abs(a-sorted(a))==i]]for i in~-a]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=XVVLrtowFJ1VKt2EZy88BTUOjj9PYiVpBo4gaiQgKPAGTLqRTpCqdk_tamrfjx3egBDb955z7s_5-edyv32fzo9fw-7b7_fbsLF_vx79qd974d_a9tW3vr8WfnOd5tthX_j1ercbu26YZjGK8fxj4zt0-_fpyzBPJ3F-P13uYjxdgoPw8-zvq1W09qXog4No21aWYluKuivDQsYnrDpYx9dSqFLAQQtGCmziQ5KVBKtgqz4u8TysGtiQgKUZGl5qcmsiSbJHURocDQOHnYZcwrmJrxoVJR0GGIKBBW_2iEc6iYcwLB1BJCYza_BFsQHNgQTFp1vidSAZFFBybI63WaA4FsSKkVDRCk0dAdQfsmqAXFYA5jgi9VQtnZRYAjK5FrLCeAkRgRrAqhnLAG5gk_FHyOnVJPjkoFMCLHLkym2T4IigAVzG4BUw18AsqRPAA21s3KXey6lFBVIlFpmqp5aZ0onAIZ1CEkrfQhEyY4yGtxMe15OAUMM2K9ku5OQZsRQiEkrs2ahHUtNXaYgQl3uRqtOkNKMUl6gs4zx3LrMBiNRPPaNyARIrdiFVwuZENKgWtZAw3OQO5SZoGM4uUlJRvTRlhRQ45NCIhQMFyJQnh-SKM0JFMtQXVaponjNMec1qME2owpIIQ5LRX6LOhkZc8oxKt1ApEzl1RUWyzaJn8BKS2LskX1G78ayjYb5LOFbqE8BSaVSZwuVQACnSL1o7Ku3eVp_99XoIVzdd-O3rMB5vh7nop-lYDgXc6PEzsO7Cl4CM-vXqMo_nW_Fyid77lzV-Ex4P_P8P)
#### Python/NumPy, 49 bytes
```
lambda a:[[*a[(a-sorted(a))**2==i*i]]for i in~-a]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=XVXLjtowFN1VKv0J74agIMXB8WMkviTNwgiiiQQEBWbBpj8yG6RR-0_t19S-DzvMghDb955z7sv5-HO5397G8-Oz3_78_X7r1_avPPrTbu-Ff23blW-Xfn0dp9thv_RFsVrV2-2wGrquHycxiOH8a-07dPz37Uc_jSdxfj9d7mI4XYKX8NPk74tFtPal2AUH0batLMWmFHVXhoWMT1h1sI6vpVClgIMWjBTYxIckKwlWwVZ9XeJ5WDWwIQFLMzS81OTWRJJkj6I0OBoGDjsNuYRzE181Kko6DDAEAwve7BGPdBIPYVg6gkhMZtbgi2IDmgMJik83xOtAMiig5NgcbzNDcSyIFSOhohWaOgKov2TVALmsAMxxROqpWjopsQRkci1khfESIgI1gFUzlgHcwCbjj5DTq0nwyUGnBFjkyJXbJMERQQO4jMErYK6BWVIngAfa2LhLvZdTiwqkSiwyVU_NM6UTgUM6hSSUvpkiZMYYDW8nPK4nAaGGTVaymcnJM2IpRCSU2LNRj6Smr9IQIS73IlWnSWlGKS5RWcZ57lxmAxCpn3pG5QIkVuxCqoTNiWhQLWohYbjJHcpN0DCcnaWkonppygopcMihEQsHCpApTw7JFWeEimSoL6pU0TxnmPKa1WCaUIUlEYYko79EnQ2NuOQZlW6mUiZy6oqKZJtZz-AlJLF3Sb6iduNZR8N8l3Cs1CeApdKoMoXLoQBSpJ-1dlTavS6---v1EK5uuvXbVT8cb4dpuRvHY9kv4UaP34KiK7ZbMtoVi8s0nG_Ll0v03r8U-E14PPD_Pw)
Avoiding explicit numpy import saves 15.
#### Python/NumPy, 64 bytes
```
lambda a:[[*a[abs(a-sort(a))==i]]for i in~-a]
from numpy import*
```
[Attempt This Online!](https://ato.pxeger.com/run?1=XVVLrtowFB11UFbh2QsoSHFw_HkSUveRZmAEUSMBQSFvwKQb6QSpavfULqMrqH0_dt4bALF97znn3nscfvy-PeZv4_X5s99__fU291v758vZXw5HL_xr22586w_3wm_v4zQXfr3e74eu68dJDGK4ft_6btVP40Vc3y63hxgutxC2QZy_n_7FOF-KQwgVbdvKUuxKUXdlWMj4DasO1vGxFKoUcNBCkIKY-CUpSkJUiFUfl3geVg1sSMDSDA0PNaU1kSTFoygNiYaBw05DKeHcxEeNipIOAwwhwEI2Z8QjncRDGZaOoBKTmTXkotiA5kCC4tMd8TqQDAqoOTbX2yxQHAtixUioaIWhjgDqD101QC4rAHNckXo3LZ2UWAIyeRaywnoJEYEawKoZywBuYJPxQ8jp0ST4lKBTAyxy5MntkuCIoAFcxuIVMNfALMkJkIExNu6S93JrUYFUiUWm6allp3QicEinkITat1CEzFij4e2Ex_MkINSwy0p2Czn5jlgqEQklejbqkWT6Kl0ixGUv0nSa1GaU4hKVZZz3zmU2AJH6nWdUHkBiRRfSJGxuRINqUQsJw012KJugYTi7aElF89LUFVLgkEMjFl4oQKY-OSRX3BEakiFfVGmi-Z5hy2tWg21CFZZEGJKM-RJ1NnTFJd9R6RYqZSInV1Qk2yw8gy8hid4l-YrsxncdA_O7hGslnwCWSleVKVwuBZAi_cLaUWn3uvrs7_fTNIv4oj8di3bTD-f5NBWHcTyXfeGnyT_iH8C6C_8BFHRYr27TcJ2Ll1vMPr6s8dX_fOLvfw)
This version exploits that OP doesn't care for order.
#### Python/NumPy, 71 bytes
```
lambda a:[[*a[abs(a-sort(a))==i]]for i in sort(a)-1]
from numpy import*
```
[Attempt This Online!](https://ato.pxeger.com/run?1=XVU7jtswEK1SxKdgt7YhAxqZ4mcB1zmEooLGrrACbMuQtYXPksZAkNwpKXOSiPMhtVvYFsmZ997MPMo_fl_v09twefzsDt9_vU_dzv35dgrn40tQ4blptqEJx9s67G7DOK3DZnM49G3bDaPqVX9RvLuDdtWNw1ld3s_Xu-rP13l_S3B_v_yL4aFQx5jRNA0Ual-oqi3mBcRvXLW4jo-F0oXCgwaDNMbEL-AowKg5Vn9e0vm8qnEDEMsIND5UnFZHkhRPogwmWgGed2pOmc9tfDSkKOmwyDAHOMyWjHhkkngsw_ERVmIzs8FcEjujeZSg5XTPvB4lowJujsv11gsUL4JEMRFqXlGoZ4DqU1ctkkOJYF4q0h-mZZISx0A2zwJKqpcRCahGrEqwLOLObBA_jJwebYJPCSY1wBFHntw-CY4IBsEhFq-RuUJmYCdgBsW4uMvey60lBaATC6Tp6WWnTCLwRKeJhNu3UETMVKOV7YQn82Qg0rDPSvYLOfmOOC6RCIE8G_UAm75Ml4hwxYs8nTq1maT4ROUE56NzhQ1BwHzwjM4DSKzkQp6Ey42oSS1pYWG0KQ4VE9QC5xYtKXlehrvCCjxxGMKiC4XI3CdP5Fo6wkOy7IsyTTTfM2p5JWqoTaTCsQjLkikfSGfNVxzkjoJfqIREzq4oWbZdeIZeQkDeZfma7SZ3nQLzu0RqZZ8glk5XVSh8LgWRIv3C2lFp-7z6Gm6313FSzbbrT9PruD4Ow6no1mEcwz3-AWzaw-G4uo79ZVo_XWP0y9OGXvWPB_3-Bw)
Expects a numpy array but outputs a plain list of lists instead of a list of arrays which would be 3 bytes shorter but looks rather ugly.
[Answer]
# [Arturo](https://arturo-lang.io), 34 bytes
```
$=>[0gather&=>[abs&-dup+1]|values]
```
[Try it](http://arturo-lang.io/playground?rtSwmo)
]