# Get closest matched strings

**URL:** <https://forum.dynamobim.com/t/get-closest-matched-strings/115159>\
**Category:** Revit\
**Tags:** revit, dynamo\
**Created:** [August 29, 2026, 7:42pm UTC](https://forum.dynamobim.com/t/get-closest-matched-strings/115159 "2026-08-29T19:42:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdelrahmanelfeky6](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@abdelrahmanelfeky6](https://forum.dynamobim.com/u/abdelrahmanelfeky6)\
**Post date:** [August 29, 2026, 7:42pm UTC](https://forum.dynamobim.com/t/get-closest-matched-strings/115159/1 "2026-08-29T19:42:44Z")

</div>

Hello

lets say i have 2 lists

list a [bedroom , livingroom , KITCHED]

list b [kitchen, bed room , living]

so how can i sort them to have same order by closest text

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [August 29, 2026, 7:59pm UTC](https://forum.dynamobim.com/t/get-closest-matched-strings/115159/2 "2026-08-29T19:59:05Z")

</div>

Hi maybe List.Sort could work in that case

 ![Skærmbillede 2026-08-29 215327](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/a/6a4f4a1f59521cb1cdc603df05767b9d258a3e76.png)

---

<div class="post-metadata">

**Author:** ![abdelrahmanelfeky6](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@abdelrahmanelfeky6](https://forum.dynamobim.com/u/abdelrahmanelfeky6)\
**Post date:** [August 29, 2026, 8:33pm UTC](https://forum.dynamobim.com/t/get-closest-matched-strings/115159/3 "2026-08-29T20:33:42Z")

</div>

ty but in my case i have 3 rooms name in a list (from excel)

and on the other list i have 20+ rooms name (all rooms in project)

so in my casei think sort wont work

its like, i want the index of the closest text from list 2

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [August 29, 2026, 9:07pm UTC](https://forum.dynamobim.com/t/get-closest-matched-strings/115159/4 "2026-08-29T21:07:13Z")

</div>

allright then try string remove with start index 3 and a string length - 3 as count, and use a string to lower in your first list and use List.AllIndicesOf for get sort index…maybe if i understand 😉  
PS btw why not just spell it right ?  
here is a fast example with the princip with these 2 list you showed

 ![Skærmbillede 2026-08-29 233412](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/5/5549958db813b45d6b44ef04c2b46dc5e33f0f5a.png)

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [August 30, 2026, 12:45am UTC](https://forum.dynamobim.com/t/get-closest-matched-strings/115159/5 "2026-08-30T00:45:56Z")

</div>

> **[Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance)**
>
> In information theory, linguistics, and computer science, the Levenshtein distance is a string metric for measuring the difference between two sequences. The Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other. It is named after Soviet mathematician Vladimir Levenshtein, who defined the metric in 1965. Levenshtein distance may also be referred to as edit distance, although that t...

AI should be able to smash some python out if you ask for this algorithm to be used. Force it all to lower case if case invariant first, as well as trim left/right to get rid of whitespace either end.

I think a package out there might have a node for this, I’ll look into it for my own potentially…

Google AI py example:

> **[Google Search](https://www.google.com/share.google?q=aimode%2Fz3ij8D8gmv043ktW7)**

Edit: Here’s a C# Proof of concept:

> <https://github.com/aussieBIMguru/Pickles/blob/8a646a4aa4e98a00bdff26b1173638d104a8a2ea/src/PicklesRevit/Extensions/Ext_String.cs#L209>

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/4/349e9fd498994b34651164605e0002a6cccfc8bc.png)
