scoreboard players set min times_appeared 0

execute if score #lightsaber shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = lightsaber times_appeared
execute if score #lightsaber shop matches 1 if score lightsaber times_appeared < min times_appeared run scoreboard players operation min times_appeared = lightsaber times_appeared

execute if score #long_sword shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = long_sword times_appeared
execute if score #long_sword shop matches 1 if score long_sword times_appeared < min times_appeared run scoreboard players operation min times_appeared = long_sword times_appeared

execute if score #lightning_hammer shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = lightning_hammer times_appeared
execute if score #lightning_hammer shop matches 1 if score lightning_hammer times_appeared < min times_appeared run scoreboard players operation min times_appeared = lightning_hammer times_appeared

execute if score #falchion shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = falchion times_appeared
execute if score #falchion shop matches 1 if score falchion times_appeared < min times_appeared run scoreboard players operation min times_appeared = falchion times_appeared

execute if score #coin_sword shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = coin_sword times_appeared
execute if score #coin_sword shop matches 1 if score coin_sword times_appeared < min times_appeared run scoreboard players operation min times_appeared = coin_sword times_appeared

execute if score #doubble_bladed_glaive shop matches 1 if score min times_appeared matches -1 run scoreboard players operation min times_appeared = doubble_bladed_glaive times_appeared
execute if score #doubble_bladed_glaive shop matches 1 if score doubble_bladed_glaive times_appeared < min times_appeared run scoreboard players operation min times_appeared = doubble_bladed_glaive times_appeared
execute if score min times_appeared matches -1 run scoreboard players set min times_appeared 0