code: def test_heapset_sorted_flag_right():
      "Verify right operations don't affect sortedness"
      heap = HeapSet(key=operator.attrgetter("i"))
      c1 = C("1", 1)
      c2 = C("2", 2)
      c3 = C("3", 3)
  
      heap.add(c2)
      heap.add(c3)
      heap.add(c1)
  
      assert not heap._sorted
      list(heap.sorted())
      assert_heap_sorted(heap)
  
      assert heap.peekright() is c3
      assert_heap_sorted(heap)
      assert heap.popright() is c3
      assert_heap_sorted(heap)
      assert heap.popright() is c2
      assert_heap_sorted(heap)
  
      heap.add(c2)
      assert not heap._sorted
      assert heap.popright() is c2
      assert not heap._sorted
      assert heap.popright() is c1
      assert not heap
      assert_heap_sorted(heap)
  
imports: from __future__ import annotations
  import heapq
  import operator
  import pickle
  import random
  from collections.abc import Mapping
  import pytest
  from distributed.collections import LRU, HeapSet, sum_mappings
label_desc: Use image node_id 5 for calling a global function with example usage: test_heapset_sorted_flag_right() without return types