{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreifylbdbcusiyoom34mwcass5cpc2vklxujvpjglfgkpmhiio6fwba",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mjntmpp4kxi2"
  },
  "path": "/t/t-sort-by-index-and-t-sort-by-key-and-index/24172#post_18",
  "publishedAt": "2026-04-17T00:52:16.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "zackw:\n\n> I feel like there ought to be a way to detect missing values (or, equivalently, duplicates) in O(1) space\n\nIf you can stomach requiring mutable access to the permutation, you could use the slice itself for the necessary memory. For `&mut [usize]` to be a valid permutation, each element must have a zero MSB. Using those as an N-element bitset, you could check the permutation in O(N) time and no _additional_ space.",
  "title": "`<[T]>::sort_by_index` and `<[T]>::sort_by_key_and_index`"
}