I Want to split list into two lists right_order[] and reverse_order[], while comparing items in list
I have result list where it has both ordered items like A, B and B, A combis or it can be 1,2 and 2,1 etc, if we found any reverse combis for A, B or 1,2 or 3211, 3222 or anything then reversed combis should store in target_list and correct ordered combis should store in source_list. also if we don't find any reverse combis then add that to source_list but target_list must contain only reverse combis of items in source_list if we found.
Here is my code, I'm getting only for A, B combis can you tell how can I do dynamically like in place of A it can be anything and in place of B it can be anything that should satisfy the above-explained condition
result = [('A','B', 'IP1','GP1'), ('B', 'C', 'IP2','GP2'),('A', 'C', 'IP3','GP2'),('A','B', 'IP4','GP2'),('D', 'Z', 'IP5','GP2'),('B', 'A', 'IP6','GP2'), ('C','B','IP7','GP2'), ('C', 'A', 'IP8','GP2'),('C','B','IP9','GP2')]
a=[i for i,v in enumerate(result) if v[:2]==('B','A')]
Source_list,target_list=result[:a[0]],result[a[0]:]
print(Source_list)
print(target_list)
output:
[('A', 'B', 'IP1', 'GP1'), ('B', 'C', 'IP2', 'GP2'), ('A', 'C', 'IP3', 'GP2'), ('A', 'B', 'IP4', 'GP2'), ('D', 'Z', 'IP5', 'GP2')]
[('B', 'A', 'IP6', 'GP2'), ('C', 'B', 'IP7', 'GP2'), ('C', 'A', 'IP8', 'GP2'), ('C', 'B', 'IP9', 'GP2')]
python python-3.x python-2.7 list-comprehension
add a comment |
I have result list where it has both ordered items like A, B and B, A combis or it can be 1,2 and 2,1 etc, if we found any reverse combis for A, B or 1,2 or 3211, 3222 or anything then reversed combis should store in target_list and correct ordered combis should store in source_list. also if we don't find any reverse combis then add that to source_list but target_list must contain only reverse combis of items in source_list if we found.
Here is my code, I'm getting only for A, B combis can you tell how can I do dynamically like in place of A it can be anything and in place of B it can be anything that should satisfy the above-explained condition
result = [('A','B', 'IP1','GP1'), ('B', 'C', 'IP2','GP2'),('A', 'C', 'IP3','GP2'),('A','B', 'IP4','GP2'),('D', 'Z', 'IP5','GP2'),('B', 'A', 'IP6','GP2'), ('C','B','IP7','GP2'), ('C', 'A', 'IP8','GP2'),('C','B','IP9','GP2')]
a=[i for i,v in enumerate(result) if v[:2]==('B','A')]
Source_list,target_list=result[:a[0]],result[a[0]:]
print(Source_list)
print(target_list)
output:
[('A', 'B', 'IP1', 'GP1'), ('B', 'C', 'IP2', 'GP2'), ('A', 'C', 'IP3', 'GP2'), ('A', 'B', 'IP4', 'GP2'), ('D', 'Z', 'IP5', 'GP2')]
[('B', 'A', 'IP6', 'GP2'), ('C', 'B', 'IP7', 'GP2'), ('C', 'A', 'IP8', 'GP2'), ('C', 'B', 'IP9', 'GP2')]
python python-3.x python-2.7 list-comprehension
add a comment |
I have result list where it has both ordered items like A, B and B, A combis or it can be 1,2 and 2,1 etc, if we found any reverse combis for A, B or 1,2 or 3211, 3222 or anything then reversed combis should store in target_list and correct ordered combis should store in source_list. also if we don't find any reverse combis then add that to source_list but target_list must contain only reverse combis of items in source_list if we found.
Here is my code, I'm getting only for A, B combis can you tell how can I do dynamically like in place of A it can be anything and in place of B it can be anything that should satisfy the above-explained condition
result = [('A','B', 'IP1','GP1'), ('B', 'C', 'IP2','GP2'),('A', 'C', 'IP3','GP2'),('A','B', 'IP4','GP2'),('D', 'Z', 'IP5','GP2'),('B', 'A', 'IP6','GP2'), ('C','B','IP7','GP2'), ('C', 'A', 'IP8','GP2'),('C','B','IP9','GP2')]
a=[i for i,v in enumerate(result) if v[:2]==('B','A')]
Source_list,target_list=result[:a[0]],result[a[0]:]
print(Source_list)
print(target_list)
output:
[('A', 'B', 'IP1', 'GP1'), ('B', 'C', 'IP2', 'GP2'), ('A', 'C', 'IP3', 'GP2'), ('A', 'B', 'IP4', 'GP2'), ('D', 'Z', 'IP5', 'GP2')]
[('B', 'A', 'IP6', 'GP2'), ('C', 'B', 'IP7', 'GP2'), ('C', 'A', 'IP8', 'GP2'), ('C', 'B', 'IP9', 'GP2')]
python python-3.x python-2.7 list-comprehension
I have result list where it has both ordered items like A, B and B, A combis or it can be 1,2 and 2,1 etc, if we found any reverse combis for A, B or 1,2 or 3211, 3222 or anything then reversed combis should store in target_list and correct ordered combis should store in source_list. also if we don't find any reverse combis then add that to source_list but target_list must contain only reverse combis of items in source_list if we found.
Here is my code, I'm getting only for A, B combis can you tell how can I do dynamically like in place of A it can be anything and in place of B it can be anything that should satisfy the above-explained condition
result = [('A','B', 'IP1','GP1'), ('B', 'C', 'IP2','GP2'),('A', 'C', 'IP3','GP2'),('A','B', 'IP4','GP2'),('D', 'Z', 'IP5','GP2'),('B', 'A', 'IP6','GP2'), ('C','B','IP7','GP2'), ('C', 'A', 'IP8','GP2'),('C','B','IP9','GP2')]
a=[i for i,v in enumerate(result) if v[:2]==('B','A')]
Source_list,target_list=result[:a[0]],result[a[0]:]
print(Source_list)
print(target_list)
output:
[('A', 'B', 'IP1', 'GP1'), ('B', 'C', 'IP2', 'GP2'), ('A', 'C', 'IP3', 'GP2'), ('A', 'B', 'IP4', 'GP2'), ('D', 'Z', 'IP5', 'GP2')]
[('B', 'A', 'IP6', 'GP2'), ('C', 'B', 'IP7', 'GP2'), ('C', 'A', 'IP8', 'GP2'), ('C', 'B', 'IP9', 'GP2')]
python python-3.x python-2.7 list-comprehension
python python-3.x python-2.7 list-comprehension
edited Nov 16 '18 at 8:15
atline
3,159102138
3,159102138
asked Nov 16 '18 at 7:32
smily dipssmily dips
358
358
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I'm not really sure to understood what you what but you'll tell me...
def kamoulox(results):
source_list =
target_list =
combis = set((result[0], result[1]) for result in results if result[0] <= result[1])
for combi in combis:
i = 0
while i < len(results):
if results[i][0:2] == combi:
source_list.append(results.pop(i))
elif results[i][0:2] == combi[::-1]:
target_list.append(results.pop(i))
else:
i += 1
return source_list, target_list
results = [
('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')
]
source_list, target_list = kamoulox(results)
# source_list contains good ordered items (with or without reversed equivalent)
# target_list contains wrong ordered items with at least one equivalent into source_list
# results now contains wrong ordered items without good ordered equivalent
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333305%2fi-want-to-split-list-into-two-lists-right-order-and-reverse-order-while-com%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm not really sure to understood what you what but you'll tell me...
def kamoulox(results):
source_list =
target_list =
combis = set((result[0], result[1]) for result in results if result[0] <= result[1])
for combi in combis:
i = 0
while i < len(results):
if results[i][0:2] == combi:
source_list.append(results.pop(i))
elif results[i][0:2] == combi[::-1]:
target_list.append(results.pop(i))
else:
i += 1
return source_list, target_list
results = [
('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')
]
source_list, target_list = kamoulox(results)
# source_list contains good ordered items (with or without reversed equivalent)
# target_list contains wrong ordered items with at least one equivalent into source_list
# results now contains wrong ordered items without good ordered equivalent
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
add a comment |
I'm not really sure to understood what you what but you'll tell me...
def kamoulox(results):
source_list =
target_list =
combis = set((result[0], result[1]) for result in results if result[0] <= result[1])
for combi in combis:
i = 0
while i < len(results):
if results[i][0:2] == combi:
source_list.append(results.pop(i))
elif results[i][0:2] == combi[::-1]:
target_list.append(results.pop(i))
else:
i += 1
return source_list, target_list
results = [
('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')
]
source_list, target_list = kamoulox(results)
# source_list contains good ordered items (with or without reversed equivalent)
# target_list contains wrong ordered items with at least one equivalent into source_list
# results now contains wrong ordered items without good ordered equivalent
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
add a comment |
I'm not really sure to understood what you what but you'll tell me...
def kamoulox(results):
source_list =
target_list =
combis = set((result[0], result[1]) for result in results if result[0] <= result[1])
for combi in combis:
i = 0
while i < len(results):
if results[i][0:2] == combi:
source_list.append(results.pop(i))
elif results[i][0:2] == combi[::-1]:
target_list.append(results.pop(i))
else:
i += 1
return source_list, target_list
results = [
('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')
]
source_list, target_list = kamoulox(results)
# source_list contains good ordered items (with or without reversed equivalent)
# target_list contains wrong ordered items with at least one equivalent into source_list
# results now contains wrong ordered items without good ordered equivalent
I'm not really sure to understood what you what but you'll tell me...
def kamoulox(results):
source_list =
target_list =
combis = set((result[0], result[1]) for result in results if result[0] <= result[1])
for combi in combis:
i = 0
while i < len(results):
if results[i][0:2] == combi:
source_list.append(results.pop(i))
elif results[i][0:2] == combi[::-1]:
target_list.append(results.pop(i))
else:
i += 1
return source_list, target_list
results = [
('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'),
('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'),
('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'),
('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'),
('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'),
('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')
]
source_list, target_list = kamoulox(results)
# source_list contains good ordered items (with or without reversed equivalent)
# target_list contains wrong ordered items with at least one equivalent into source_list
# results now contains wrong ordered items without good ordered equivalent
edited Nov 16 '18 at 20:27
answered Nov 16 '18 at 8:06
DylannCordelDylannCordel
39538
39538
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
add a comment |
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
Sorry it is not generating correct output can you try with actual data of mine result [('32891', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32822', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32822', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('32822', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('32822', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32891', 'EKRGMD92-vMME-02', '10.88.159.113'),
– smily dips
Nov 16 '18 at 8:32
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
('33033', '32891', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32891', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('33033', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('33033', '32781', 'EKRGMD92-vMME-02', '10.88.159.113'), ('33033', '32781', 'HRSNNJAQ-vMME-01', '10.88.162.81'), ('33033', '32781', 'HRSNNJAQ-vMME-02', '10.88.163.113'), ('32781', '32891', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '32822', 'EKRGMD92-vMME-01', '10.88.158.81'), ('32781', '32822', 'KSCYMOEC-MME-03', '10.148.9.19'), ('32781', '33033', 'KSCYMOEC-MME-03', '10.148.9.19')]
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Sorry I don't have space to post entire list so can you take list from two comments
– smily dips
Nov 16 '18 at 8:35
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
Fixed. That should do what I understood of what you want.
– DylannCordel
Nov 16 '18 at 20:29
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
This isn't fixed for huge data like atleast 7000 of tuples it is taking too much of time to loop for each and every 7000 combis and 7000 tuples, instead can i use itertools to make it fast? if yes how?
– smily dips
Nov 18 '18 at 12:42
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333305%2fi-want-to-split-list-into-two-lists-right-order-and-reverse-order-while-com%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown