Sorting in electronics way

formula for B1:

=1*SUBSTITUTE(A1;REGEX(A1;"[RkMG]");VLOOKUP(REGEX(A1;"[RkMG]");$G$1:$H$4;2;0))

Content of G1:H4

R ,
k 000,
M 000000,
G 000000000,

resistor_sort.ods (12.4 KB)
in case your use decimalpoint instead decimalcomma change Column H to your needs

bonus: Direct Sort of CurrentSelection by Resistor_syntax in python:
edit: corrections in python

import re

rex = re.compile(r'([RkMG])')

def repl(resistor):
    value, unit, decimals = rex.split(resistor[0])
    return ("RkMG".index(unit), float(f"{value}.{decimals}"))
    
def sort_resistors():    
    sel = XSCRIPTCONTEXT.getDocument().CurrentSelection
    resistors = sel.DataArray
    sel.DataArray = sorted(resistors, key=repl)
1 Like

Without auxiliary ranges and taking into account different fraction separators.

=VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1; "R"; "|"); "k"; "000|");"M";"000000|") ;"G";"000000000|");"|";MID(3/2;2;1)))
1 Like

This solution is way shorter and probably easy to understand

=(REGEX(A2,"\D",".")) *(10^(3*(FIND(REGEX(A2,"\d","","g"),"RkMG",1)-1)))